Merge pull request #24 from SonOfGib/AAP-1.6-crankshaft
Aap 1.6 crankshaft
This commit is contained in:
commit
82bffdb514
216
CMakeLists.txt
216
CMakeLists.txt
@ -1,115 +1,177 @@
|
||||
cmake_minimum_required(VERSION 3.5.1)
|
||||
if(CROSS_COMPILE_ARMHF)
|
||||
message("Cross compiling for armhf")
|
||||
set(CMAKE_C_COMPILER /usr/bin/arm-linux-gnueabihf-gcc-8)
|
||||
set(CMAKE_CXX_COMPILER /usr/bin/arm-linux-gnueabihf-g++-8)
|
||||
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "armhf")
|
||||
endif(CROSS_COMPILE)
|
||||
|
||||
project(openauto CXX)
|
||||
|
||||
message(STATUS "OpenAuto")
|
||||
|
||||
option(NOPI "Build for Non Raspberry Pi" OFF)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(base_directory ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set(resources_directory ${base_directory}/assets)
|
||||
set(sources_directory ${base_directory}/src)
|
||||
set(include_directory ${base_directory}/include)
|
||||
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${base_directory}/lib)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${base_directory}/lib)
|
||||
# Set Compile Versions
|
||||
set(OPENAUTO_BUILD_DATE 20241124) # Binary Release Build Date
|
||||
set(OPENAUTO_BUILD_MAJOR_RELEASE 4) # Binary Release Build Major Number
|
||||
set(OPENAUTO_BUILD_MINOR_RELEASE 1) # Binary Release Build Minor Number
|
||||
set(OPENAUTO_BUILD_INCREMENTAL 0) # Binary Build Version - Increment for Each Build
|
||||
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${base_directory}/bin)
|
||||
set(EXECUTABLE_OUTPUT_PATH ${base_directory}/bin)
|
||||
|
||||
set(Boost_USE_STATIC_LIBS OFF)
|
||||
set(Boost_USE_MULTITHREADED ON)
|
||||
set(Boost_USE_STATIC_RUNTIME OFF)
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake_modules/")
|
||||
SET(CMAKE_CXX_STANDARD 14)
|
||||
# Configure CMAKE
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_INIT} -Wall -pedantic -fPIC")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-g -O3")
|
||||
|
||||
# Default to Release mode unless overridden with -DCMAKE_BUILD_TYPE=Debug on cmake command
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
message(STATUS "Forcing Release build type")
|
||||
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
|
||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath,/usr/local/qt5/lib")
|
||||
|
||||
# Set the possible values of build type for cmake-gui
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
|
||||
endif()
|
||||
|
||||
# Paths
|
||||
set(resources_directory ${CMAKE_CURRENT_SOURCE_DIR}/assets)
|
||||
set(sources_directory ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||
set(include_directory ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib)
|
||||
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)
|
||||
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/bin)
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake_modules/")
|
||||
|
||||
# Configure Boost
|
||||
set(Boost_USE_STATIC_LIBS OFF)
|
||||
set(Boost_USE_MULTITHREADED ON)
|
||||
set(Boost_USE_STATIC_RUNTIME OFF)
|
||||
|
||||
add_definitions(-DBOOST_ALL_DYN_LINK)
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
message(STATUS "Disabling Boost DEBUG logs")
|
||||
add_definitions(-DNDEBUG)
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
set(WINSOCK2_LIBRARIES "ws2_32")
|
||||
endif (WIN32)
|
||||
|
||||
if (DEFINED NOPI)
|
||||
message(STATUS "Configuring for Non-Raspberry Pi")
|
||||
else()
|
||||
message(STATUS "Configuring for RaspberryPi")
|
||||
add_definitions(-DUSE_OMX -DOMX_SKIP64BIT -DRASPBERRYPI3)
|
||||
set(BCM_HOST_LIBRARIES "/opt/vc/lib/libbcm_host.so")
|
||||
set(BCM_HOST_INCLUDE_DIRS "/opt/vc/include")
|
||||
set(ILCLIENT_INCLUDE_DIRS "/opt/vc/src/hello_pi/libs/ilclient")
|
||||
set(ILCLIENT_LIBRARIES "/opt/vc/src/hello_pi/libs/ilclient/libilclient.a;/opt/vc/lib/libvcos.so;/opt/vc/lib/libvcilcs.a;/opt/vc/lib/libvchiq_arm.so")
|
||||
endif ()
|
||||
|
||||
# Building on a Mac requires Abseil
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") # macOS
|
||||
message(STATUS "MacOS System Detected")
|
||||
add_definitions(-DMAC_OS)
|
||||
find_package(protobuf REQUIRED CONFIG)
|
||||
find_package(absl REQUIRED)
|
||||
set(CMAKE_PREFIX_PATH "/usr/local/opt/qt@5" ${CMAKE_PREFIX_PATH})
|
||||
list(APPEND CMAKE_PREFIX_PATH /usr/local/opt/util-linux)
|
||||
list(APPEND CMAKE_PREFIX_PATH /usr/local/opt/taglib)
|
||||
include(FindProtobuf)
|
||||
else ()
|
||||
find_package(Protobuf REQUIRED)
|
||||
endif ()
|
||||
|
||||
find_package(aap_protobuf REQUIRED)
|
||||
find_package(aasdk REQUIRED)
|
||||
find_package(Boost REQUIRED COMPONENTS system log_setup log OPTIONAL_COMPONENTS unit_test_framework)
|
||||
find_package(libusb-1.0 REQUIRED)
|
||||
find_package(Qt5 COMPONENTS Multimedia MultimediaWidgets Bluetooth Network)
|
||||
find_package(Protobuf REQUIRED)
|
||||
find_package(Qt5 COMPONENTS DBus Multimedia MultimediaWidgets Bluetooth Network)
|
||||
find_package(OpenSSL REQUIRED)
|
||||
find_package(rtaudio REQUIRED)
|
||||
find_package(taglib REQUIRED)
|
||||
find_package(blkid REQUIRED)
|
||||
find_package(gps REQUIRED)
|
||||
|
||||
if(WIN32)
|
||||
set(WINSOCK2_LIBRARIES "ws2_32")
|
||||
endif(WIN32)
|
||||
|
||||
if(RPI3_BUILD)
|
||||
add_definitions(-DUSE_OMX -DOMX_SKIP64BIT -DRASPBERRYPI3)
|
||||
set(BCM_HOST_LIBRARIES "/opt/vc/lib/libbcm_host.so")
|
||||
set(BCM_HOST_INCLUDE_DIRS "/opt/vc/include")
|
||||
set(ILCLIENT_INCLUDE_DIRS "/opt/vc/src/hello_pi/libs/ilclient")
|
||||
set(ILCLIENT_LIBRARIES "/opt/vc/src/hello_pi/libs/ilclient/libilclient.a;/opt/vc/lib/libvcos.so;/opt/vc/lib/libvcilcs.a;/opt/vc/lib/libvchiq_arm.so")
|
||||
endif(RPI3_BUILD)
|
||||
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR}
|
||||
${Qt5Multimedia_INCLUDE_DIRS}
|
||||
${Qt5MultimediaWidgets_INCLUDE_DIRS}
|
||||
${Qt5Widgets_INCLUDE_DIRS}
|
||||
${Qt5Bluetooth_INCLUDE_DIRS}
|
||||
${Qt5Network_INCLUDE_DIRS}
|
||||
${Boost_INCLUDE_DIRS}
|
||||
${PROTOBUF_INCLUDE_DIR}
|
||||
${OPENSSL_INCLUDE_DIR}
|
||||
${RTAUDIO_INCLUDE_DIRS}
|
||||
${TAGLIB_INCLUDE_DIRS}
|
||||
${BLKID_INCLUDE_DIRS}
|
||||
${AASDK_PROTO_INCLUDE_DIRS}
|
||||
${AASDK_INCLUDE_DIRS}
|
||||
${BCM_HOST_INCLUDE_DIRS}
|
||||
${ILCLIENT_INCLUDE_DIRS}
|
||||
${include_directory})
|
||||
|
||||
${Qt5Multimedia_INCLUDE_DIRS}
|
||||
${Qt5MultimediaWidgets_INCLUDE_DIRS}
|
||||
${Qt5Widgets_INCLUDE_DIRS}
|
||||
${Qt5Bluetooth_INCLUDE_DIRS}
|
||||
${Qt5Network_INCLUDE_DIRS}
|
||||
${Boost_INCLUDE_DIRS}
|
||||
${OPENSSL_INCLUDE_DIR}
|
||||
${RTAUDIO_INCLUDE_DIRS}
|
||||
${TAGLIB_INCLUDE_DIRS}
|
||||
${BLKID_INCLUDE_DIRS}
|
||||
${BCM_HOST_INCLUDE_DIRS}
|
||||
${ILCLIENT_INCLUDE_DIRS}
|
||||
${include_directory}
|
||||
${PROTOBUF_INCLUDE_DIR}
|
||||
${AAP_PROTOBUF_INCLUDE_DIR}
|
||||
${AASDK_INCLUDE_DIR})
|
||||
|
||||
link_directories(${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
|
||||
|
||||
set(common_include_directory ${include_directory}/f1x/openauto/Common)
|
||||
|
||||
set(autoapp_sources_directory ${sources_directory}/autoapp)
|
||||
set(autoapp_include_directory ${include_directory}/f1x/openauto/autoapp)
|
||||
file(GLOB_RECURSE autoapp_source_files ${autoapp_sources_directory}/*.ui ${autoapp_sources_directory}/*.cpp ${autoapp_include_directory}/*.hpp ${common_include_directory}/*.hpp ${resources_directory}/*.qrc)
|
||||
|
||||
file(GLOB_RECURSE autoapp_source_files ${autoapp_sources_directory}/*.ui ${autoapp_sources_directory}/*.cpp ${autoapp_include_directory}/*.hpp ${autoapp_include_directory}/*.h ${common_include_directory}/*.hpp ${resources_directory}/*.qrc)
|
||||
|
||||
add_executable(autoapp ${autoapp_source_files})
|
||||
|
||||
target_link_libraries(autoapp libusb
|
||||
${Boost_LIBRARIES}
|
||||
${Qt5Multimedia_LIBRARIES}
|
||||
${Qt5MultimediaWidgets_LIBRARIES}
|
||||
${Qt5Bluetooth_LIBRARIES}
|
||||
${Qt5Network_LIBRARIES}
|
||||
${PROTOBUF_LIBRARIES}
|
||||
${BCM_HOST_LIBRARIES}
|
||||
${ILCLIENT_LIBRARIES}
|
||||
${WINSOCK2_LIBRARIES}
|
||||
${RTAUDIO_LIBRARIES}
|
||||
${TAGLIB_LIBRARIES}
|
||||
${BLKID_LIBRARIES}
|
||||
${GPS_LIBRARIES}
|
||||
${AASDK_PROTO_LIBRARIES}
|
||||
${AASDK_LIBRARIES})
|
||||
target_include_directories(autoapp PUBLIC ${AAP_PROTOBUF_INCLUDE_DIR} ${AASDK_INCLUDE_DIR})
|
||||
|
||||
target_link_libraries(autoapp PUBLIC
|
||||
libusb
|
||||
${Boost_LIBRARIES}
|
||||
${Qt5DBus_LIBRARIES}
|
||||
${Qt5Multimedia_LIBRARIES}
|
||||
${Qt5MultimediaWidgets_LIBRARIES}
|
||||
${Qt5Bluetooth_LIBRARIES}
|
||||
${Qt5Network_LIBRARIES}
|
||||
${BCM_HOST_LIBRARIES}
|
||||
${ILCLIENT_LIBRARIES}
|
||||
${WINSOCK2_LIBRARIES}
|
||||
${RTAUDIO_LIBRARIES}
|
||||
${TAGLIB_LIBRARIES}
|
||||
${BLKID_LIBRARIES}
|
||||
${GPS_LIBRARIES}
|
||||
${PROTOBUF_LIBRARIES}
|
||||
${AAP_PROTOBUF_LIB_DIR}
|
||||
${AASDK_LIB_DIR})
|
||||
|
||||
set(PROGRAM_VERSION_STRING "${OPENAUTO_BUILD_MAJOR_RELEASE}.${OPENAUTO_BUILD_MINOR_RELEASE}.${OPENAUTO_BUILD_INCREMENTAL}+${OPENAUTO_BUILD_DATE}")
|
||||
|
||||
message(STATUS "Project Version: ${PROGRAM_VERSION_STRING}")
|
||||
|
||||
set(btservice_sources_directory ${sources_directory}/btservice)
|
||||
|
||||
set(btservice_include_directory ${include_directory}/f1x/openauto/btservice)
|
||||
file(GLOB_RECURSE btservice_source_files ${btservice_sources_directory}/*.cpp ${btservice_include_directory}/*.hpp ${autoapp_sources_directory}/Configuration/*.cpp ${autoapp_includes_directory}/Configuration/*.hpp ${common_include_directory}/*.hpp)
|
||||
|
||||
add_executable(btservice ${btservice_source_files})
|
||||
add_executable(btservice ${btservice_source_files}
|
||||
src/btservice/BluetoothHandler.cpp)
|
||||
|
||||
target_link_libraries(btservice
|
||||
${Boost_LIBRARIES}
|
||||
${Qt5Bluetooth_LIBRARIES}
|
||||
${Qt5Network_LIBRARIES}
|
||||
${Qt5MultimediaWidgets_LIBRARIES}
|
||||
${PROTOBUF_LIBRARIES}
|
||||
${AASDK_PROTO_LIBRARIES})
|
||||
target_link_libraries(btservice PUBLIC
|
||||
${Boost_LIBRARIES}
|
||||
${Qt5Bluetooth_LIBRARIES}
|
||||
${Qt5Network_LIBRARIES}
|
||||
${Qt5MultimediaWidgets_LIBRARIES}
|
||||
${PROTOBUF_LIBRARIES}
|
||||
${AAP_PROTOBUF_LIB_DIR})
|
||||
|
||||
set_target_properties(autoapp
|
||||
PROPERTIES VERSION ${PROGRAM_VERSION_STRING} SOVERSION ${OPENAUTO_BUILD_INCREMENTAL})
|
||||
|
||||
# Install rules
|
||||
#install(TARGETS autoapp btservice
|
||||
# EXPORT aasdkTargets
|
||||
# RUNTIME DESTINATION bin
|
||||
#)
|
3
Dockerfile
Normal file
3
Dockerfile
Normal file
@ -0,0 +1,3 @@
|
||||
FROM scratch
|
||||
ADD rootfs.tar.xz /
|
||||
CMD ["bash"]
|
15
RELEASE.txt
Normal file
15
RELEASE.txt
Normal file
@ -0,0 +1,15 @@
|
||||
Release Notes
|
||||
|
||||
20241124 - 4.1.0 - Bluetooth Updates
|
||||
* Rename BluetootAdapterType to BluetoothAdapterType, and change from NONE, LOCAL, REMOTE to NONE, LOCAL, EXTERNAL to better match available settings
|
||||
* getLocalAddress() on Dummy, Local and Remote bluetooth changed to getAdapterAddress()
|
||||
* Removed RemoteBluetoothDevice replacing all references with LocalBluetoothDevice. RemoteBluetoothDevice is a wrapper essentially with all pairing work handled by btservice.
|
||||
* Pairing overlaps between btservice and LocalBluetoothDevice - removed duplicated elements from LocalBluetoothDevice to rely on btservice.
|
||||
* Swap Bluetooth dropdown in Settings from none, builtin or external, to showing a list of detected Bluetooth Adapters. Write hardware address to config file.
|
||||
|
||||
20241121 - 4.0.0 - AAP 1.6 Support
|
||||
* Added support for new services provided by AASDK and AAP Protocol version 1.6.
|
||||
* Add extensive logging
|
||||
* Add logo for forked version
|
||||
* Resolve display issue where if Raspberry Pi thinks both HDMI and LCD are enabled, the display width is appearing as two side by side monitors (double width) rather than just using the physical width of the screen.
|
||||
|
BIN
assets/journey.jpg
Normal file
BIN
assets/journey.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 93 KiB |
55
cmake_modules/Findaap_protobuf.cmake
Normal file
55
cmake_modules/Findaap_protobuf.cmake
Normal file
@ -0,0 +1,55 @@
|
||||
if (AAP_PROTOBUF_LIB_DIRS AND AAP_PROTOBUF_INCLUDE_DIRS)
|
||||
# in cache already
|
||||
message(STATUS "aap_protobuf is cached")
|
||||
set(AAP_PROTOBUF_FOUND TRUE)
|
||||
else (AAP_PROTOBUF_LIB_DIRS AND AAP_PROTOBUF_INCLUDE_DIRS)
|
||||
find_path(AAP_PROTOBUF_INCLUDE_DIR
|
||||
NAMES
|
||||
channel/control/GalConstants.pb.h
|
||||
PATHS
|
||||
/usr/include
|
||||
/usr/local/include
|
||||
/opt/local/include
|
||||
/sw/include
|
||||
PATH_SUFFIXES
|
||||
aap_protobuf
|
||||
)
|
||||
|
||||
find_library(AAP_PROTOBUF_LIB_DIR
|
||||
NAMES
|
||||
aap_protobuf libaap_protobuf
|
||||
PATHS
|
||||
/usr/lib
|
||||
/usr/local/lib
|
||||
/opt/local/lib
|
||||
/sw/lib
|
||||
)
|
||||
|
||||
set(AAP_PROTOBUF_INCLUDE_DIRS
|
||||
${AAP_PROTOBUF_INCLUDE_DIR}
|
||||
)
|
||||
set(AAP_PROTOBUF_LIB_DIRS
|
||||
${AAP_PROTOBUF_LIB_DIR}
|
||||
)
|
||||
|
||||
if (AAP_PROTOBUF_INCLUDE_DIRS AND AAP_PROTOBUF_LIB_DIRS)
|
||||
set(AAP_PROTOBUF_FOUND TRUE)
|
||||
endif (AAP_PROTOBUF_INCLUDE_DIRS AND AAP_PROTOBUF_LIB_DIRS)
|
||||
|
||||
if (AAP_PROTOBUF_FOUND)
|
||||
message(STATUS "SUCCESS. Found: aap_protobuf:")
|
||||
message(STATUS " - Includes: ${AAP_PROTOBUF_INCLUDE_DIRS}")
|
||||
message(STATUS " - Libraries: ${AAP_PROTOBUF_LIB_DIRS}")
|
||||
add_library(aap_protobuf INTERFACE)
|
||||
target_include_directories(aap_protobuf SYSTEM INTERFACE ${AAP_PROTOBUF_INCLUDE_DIR})
|
||||
target_link_libraries(aap_protobuf INTERFACE ${AAP_PROTOBUF_LIB_DIR})
|
||||
else (AAP_PROTOBUF_FOUND)
|
||||
message(STATUS " - Includes: ${AAP_PROTOBUF_INCLUDE_DIRS}")
|
||||
message(STATUS " - Libraries: ${AAP_PROTOBUF_LIB_DIRS}")
|
||||
message(FATAL_ERROR "Could not locate aap_protobuf")
|
||||
endif (AAP_PROTOBUF_FOUND)
|
||||
|
||||
# show the AAP_PROTOBUF_INCLUDE_DIRS and AAP_PROTOBUF_LIB_DIRS variables only in the advanced view
|
||||
mark_as_advanced(AAP_PROTOBUF_INCLUDE_DIRS AAP_PROTOBUF_LIB_DIRS)
|
||||
|
||||
endif (AAP_PROTOBUF_LIB_DIRS AND AAP_PROTOBUF_INCLUDE_DIRS)
|
55
cmake_modules/Findaasdk.cmake
Normal file
55
cmake_modules/Findaasdk.cmake
Normal file
@ -0,0 +1,55 @@
|
||||
if (AASDK_LIB_DIRS AND AASDK_INCLUDE_DIRS)
|
||||
# in cache already
|
||||
message(STATUS "aasdk cached")
|
||||
set(AASDK_FOUND TRUE)
|
||||
else (AASDK_LIB_DIRS AND AASDK_INCLUDE_DIRS)
|
||||
find_path(AASDK_INCLUDE_DIR
|
||||
NAMES
|
||||
Version.hpp
|
||||
PATHS
|
||||
/usr/include
|
||||
/usr/local/include
|
||||
/opt/local/include
|
||||
/sw/include
|
||||
PATH_SUFFIXES
|
||||
aasdk
|
||||
)
|
||||
|
||||
find_library(AASDK_LIB_DIR
|
||||
NAMES
|
||||
aasdk libaasdk
|
||||
PATHS
|
||||
/usr/lib
|
||||
/usr/local/lib
|
||||
/opt/local/lib
|
||||
/sw/lib
|
||||
)
|
||||
|
||||
set(AASDK_INCLUDE_DIRS
|
||||
${AASDK_INCLUDE_DIR}
|
||||
)
|
||||
set(AASDK_LIB_DIRS
|
||||
${AASDK_LIB_DIR}
|
||||
)
|
||||
|
||||
if (AASDK_INCLUDE_DIRS AND AASDK_LIB_DIRS)
|
||||
set(AASDK_FOUND TRUE)
|
||||
endif (AASDK_INCLUDE_DIRS AND AASDK_LIB_DIRS)
|
||||
|
||||
if (AASDK_FOUND)
|
||||
message(STATUS "Found aasdk:")
|
||||
message(STATUS " - Includes: ${AASDK_INCLUDE_DIRS}")
|
||||
message(STATUS " - Libraries: ${AASDK_LIB_DIRS}")
|
||||
add_library(aasdk INTERFACE)
|
||||
target_include_directories(aasdk SYSTEM INTERFACE ${AASDK_INCLUDE_DIR})
|
||||
target_link_libraries(aasdk INTERFACE ${AASDK_LIB_DIR})
|
||||
else (AASDK_FOUND)
|
||||
message(STATUS " - Includes: ${AASDK_INCLUDE_DIRS}")
|
||||
message(STATUS " - Libraries: ${AASDK_LIB_DIRS}")
|
||||
message(FATAL_ERROR "Could not find aasdk")
|
||||
endif (AASDK_FOUND)
|
||||
|
||||
# show the AASDK_INCLUDE_DIRS and AASDK_LIB_DIRS variables only in the advanced view
|
||||
mark_as_advanced(AASDK_INCLUDE_DIRS AASDK_LIB_DIRS)
|
||||
|
||||
endif (AASDK_LIB_DIRS AND AASDK_INCLUDE_DIRS)
|
@ -49,7 +49,7 @@ if (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS)
|
||||
else (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS)
|
||||
find_path(LIBUSB_1_INCLUDE_DIR
|
||||
NAMES
|
||||
libusb.h
|
||||
libusb.h
|
||||
PATHS
|
||||
/usr/include
|
||||
/usr/local/include
|
||||
@ -90,12 +90,12 @@ else (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS)
|
||||
target_link_libraries(libusb INTERFACE ${LIBUSB_1_LIBRARY})
|
||||
endif (NOT libusb_1_FIND_QUIETLY)
|
||||
else (LIBUSB_1_FOUND)
|
||||
if (libusb_1_FIND_REQUIRED)
|
||||
if (libusb-1.0_FIND_REQUIRED)
|
||||
message(FATAL_ERROR "Could not find libusb")
|
||||
endif (libusb_1_FIND_REQUIRED)
|
||||
endif (libusb-1.0_FIND_REQUIRED)
|
||||
endif (LIBUSB_1_FOUND)
|
||||
|
||||
# show the LIBUSB_1_INCLUDE_DIRS and LIBUSB_1_LIBRARIES variables only in the advanced view
|
||||
mark_as_advanced(LIBUSB_1_INCLUDE_DIRS LIBUSB_1_LIBRARIES)
|
||||
|
||||
endif (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS)
|
||||
endif (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS)
|
||||
|
@ -20,4 +20,5 @@
|
||||
|
||||
#include <boost/log/trivial.hpp>
|
||||
|
||||
#define OPENAUTO_LOG(severity) BOOST_LOG_TRIVIAL(severity) << "[OpenAuto] "
|
||||
#define OPENAUTO_LOG_CONTEXT "" //"(" << typeid(*this).name() << "::" << __func__ << ")"
|
||||
#define OPENAUTO_LOG(severity) BOOST_LOG_TRIVIAL(severity) << "[OpenAuto] " << OPENAUTO_LOG_CONTEXT
|
||||
|
@ -18,23 +18,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace configuration
|
||||
{
|
||||
|
||||
enum class BluetoothAdapterType
|
||||
{
|
||||
namespace f1x::openauto::autoapp::configuration {
|
||||
|
||||
enum class BluetoothAdapterType {
|
||||
NONE,
|
||||
LOCAL,
|
||||
REMOTE
|
||||
};
|
||||
EXTERNAL
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -23,6 +23,7 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
namespace f1x
|
||||
@ -88,10 +89,10 @@ public:
|
||||
QString readFileContent(QString fileName) const override;
|
||||
QString getParamFromFile(QString fileName, QString searchString) const override;
|
||||
|
||||
aasdk::proto::enums::VideoFPS::Enum getVideoFPS() const override;
|
||||
void setVideoFPS(aasdk::proto::enums::VideoFPS::Enum value) override;
|
||||
aasdk::proto::enums::VideoResolution::Enum getVideoResolution() const override;
|
||||
void setVideoResolution(aasdk::proto::enums::VideoResolution::Enum value) override;
|
||||
aap_protobuf::service::media::sink::message::VideoFrameRateType getVideoFPS() const override;
|
||||
void setVideoFPS(aap_protobuf::service::media::sink::message::VideoFrameRateType value) override;
|
||||
aap_protobuf::service::media::sink::message::VideoCodecResolutionType getVideoResolution() const override;
|
||||
void setVideoResolution(aap_protobuf::service::media::sink::message::VideoCodecResolutionType value) override;
|
||||
size_t getScreenDPI() const override;
|
||||
void setScreenDPI(size_t value) override;
|
||||
void setOMXLayerIndex(int32_t value) override;
|
||||
@ -108,21 +109,25 @@ public:
|
||||
|
||||
BluetoothAdapterType getBluetoothAdapterType() const override;
|
||||
void setBluetoothAdapterType(BluetoothAdapterType value) override;
|
||||
std::string getBluetoothRemoteAdapterAddress() const override;
|
||||
void setBluetoothRemoteAdapterAddress(const std::string& value) override;
|
||||
std::string getBluetoothAdapterAddress() const override;
|
||||
void setBluetoothAdapterAddress(const std::string& value) override;
|
||||
bool getWirelessProjectionEnabled() const override;
|
||||
void setWirelessProjectionEnabled(bool value) override;
|
||||
|
||||
bool musicAudioChannelEnabled() const override;
|
||||
void setMusicAudioChannelEnabled(bool value) override;
|
||||
bool speechAudioChannelEnabled() const override;
|
||||
void setSpeechAudioChannelEnabled(bool value) override;
|
||||
bool guidanceAudioChannelEnabled() const override;
|
||||
void setGuidanceAudioChannelEnabled(bool value) override;
|
||||
bool systemAudioChannelEnabled() const override;
|
||||
void setSystemAudioChannelEnabled(bool value) override;
|
||||
bool telephonyAudioChannelEnabled() const override;
|
||||
void setTelephonyAudioChannelEnabled(bool value) override;
|
||||
|
||||
AudioOutputBackendType getAudioOutputBackendType() const override;
|
||||
void setAudioOutputBackendType(AudioOutputBackendType value) override;
|
||||
|
||||
private:
|
||||
void readButtonCodes(boost::property_tree::ptree& iniConfig);
|
||||
void insertButtonCode(boost::property_tree::ptree& iniConfig, const std::string& buttonCodeKey, aasdk::proto::enums::ButtonCode::Enum buttonCode);
|
||||
void insertButtonCode(boost::property_tree::ptree& iniConfig, const std::string& buttonCodeKey, aap_protobuf::service::media::sink::message::KeyCode buttonCode);
|
||||
void writeButtonCodes(boost::property_tree::ptree& iniConfig);
|
||||
|
||||
HandednessOfTrafficType handednessOfTrafficType_;
|
||||
@ -145,8 +150,8 @@ private:
|
||||
bool showAutoPlay_;
|
||||
bool instantPlay_;
|
||||
|
||||
aasdk::proto::enums::VideoFPS::Enum videoFPS_;
|
||||
aasdk::proto::enums::VideoResolution::Enum videoResolution_;
|
||||
aap_protobuf::service::media::sink::message::VideoFrameRateType videoFPS_;
|
||||
aap_protobuf::service::media::sink::message::VideoCodecResolutionType videoResolution_;
|
||||
size_t screenDPI_;
|
||||
int32_t omxLayerIndex_;
|
||||
QRect videoMargins_;
|
||||
@ -154,10 +159,14 @@ private:
|
||||
bool enablePlayerControl_;
|
||||
ButtonCodes buttonCodes_;
|
||||
BluetoothAdapterType bluetoothAdapterType_;
|
||||
std::string bluetoothAdapterAddress_;
|
||||
bool wirelessProjectionEnabled_;
|
||||
std::string bluetoothRemoteAdapterAddress_;
|
||||
bool musicAudioChannelEnabled_;
|
||||
bool speechAudiochannelEnabled_;
|
||||
|
||||
bool _audioChannelEnabledMedia;
|
||||
bool _audioChannelEnabledGuidance;
|
||||
bool _audioChannelEnabledSystem;
|
||||
bool _audioChannelEnabledTelephony;
|
||||
|
||||
AudioOutputBackendType audioOutputBackendType_;
|
||||
|
||||
static const std::string cConfigFileName;
|
||||
@ -191,12 +200,15 @@ private:
|
||||
static const std::string cVideoMarginWidth;
|
||||
static const std::string cVideoMarginHeight;
|
||||
|
||||
static const std::string cAudioMusicAudioChannelEnabled;
|
||||
static const std::string cAudioSpeechAudioChannelEnabled;
|
||||
static const std::string cAudioChannelMediaEnabled;
|
||||
static const std::string cAudioChannelGuidanceEnabled;
|
||||
static const std::string cAudioChannelSystemEnabled;
|
||||
static const std::string cAudioChannelTelephonyEnabled;
|
||||
|
||||
static const std::string cAudioOutputBackendType;
|
||||
|
||||
static const std::string cBluetoothAdapterTypeKey;
|
||||
static const std::string cBluetoothRemoteAdapterAddressKey;
|
||||
static const std::string cBluetoothAdapterAddressKey;
|
||||
static const std::string cBluetoothWirelessProjectionEnabledKey;
|
||||
|
||||
static const std::string cInputEnableTouchscreenKey;
|
||||
|
@ -20,10 +20,10 @@
|
||||
|
||||
#include <string>
|
||||
#include <QRect>
|
||||
#include <aasdk_proto/VideoFPSEnum.pb.h>
|
||||
#include <aasdk_proto/VideoResolutionEnum.pb.h>
|
||||
#include <aasdk_proto/ButtonCodeEnum.pb.h>
|
||||
#include <f1x/openauto/autoapp/Configuration/BluetootAdapterType.hpp>
|
||||
#include <aap_protobuf/service/media/sink/message/VideoFrameRateType.pb.h>
|
||||
#include <aap_protobuf/service/media/sink/message/VideoCodecResolutionType.pb.h>
|
||||
#include <aap_protobuf/service/media/sink/message/KeyCode.pb.h>
|
||||
#include <f1x/openauto/autoapp/Configuration/BluetoothAdapterType.hpp>
|
||||
#include <f1x/openauto/autoapp/Configuration/HandednessOfTrafficType.hpp>
|
||||
#include <f1x/openauto/autoapp/Configuration/AudioOutputBackendType.hpp>
|
||||
|
||||
@ -40,7 +40,7 @@ class IConfiguration
|
||||
{
|
||||
public:
|
||||
typedef std::shared_ptr<IConfiguration> Pointer;
|
||||
typedef std::vector<aasdk::proto::enums::ButtonCode::Enum> ButtonCodes;
|
||||
typedef std::vector<aap_protobuf::service::media::sink::message::KeyCode> ButtonCodes;
|
||||
|
||||
virtual ~IConfiguration() = default;
|
||||
|
||||
@ -92,10 +92,10 @@ public:
|
||||
virtual QString readFileContent(QString fileName) const = 0;
|
||||
virtual QString getParamFromFile(QString fileName, QString searchString) const = 0;
|
||||
|
||||
virtual aasdk::proto::enums::VideoFPS::Enum getVideoFPS() const = 0;
|
||||
virtual void setVideoFPS(aasdk::proto::enums::VideoFPS::Enum value) = 0;
|
||||
virtual aasdk::proto::enums::VideoResolution::Enum getVideoResolution() const = 0;
|
||||
virtual void setVideoResolution(aasdk::proto::enums::VideoResolution::Enum value) = 0;
|
||||
virtual aap_protobuf::service::media::sink::message::VideoFrameRateType getVideoFPS() const = 0;
|
||||
virtual void setVideoFPS(aap_protobuf::service::media::sink::message::VideoFrameRateType value) = 0;
|
||||
virtual aap_protobuf::service::media::sink::message::VideoCodecResolutionType getVideoResolution() const = 0;
|
||||
virtual void setVideoResolution(aap_protobuf::service::media::sink::message::VideoCodecResolutionType value) = 0;
|
||||
virtual size_t getScreenDPI() const = 0;
|
||||
virtual void setScreenDPI(size_t value) = 0;
|
||||
virtual void setOMXLayerIndex(int32_t value) = 0;
|
||||
@ -112,15 +112,19 @@ public:
|
||||
|
||||
virtual BluetoothAdapterType getBluetoothAdapterType() const = 0;
|
||||
virtual void setBluetoothAdapterType(BluetoothAdapterType value) = 0;
|
||||
virtual std::string getBluetoothRemoteAdapterAddress() const = 0;
|
||||
virtual void setBluetoothRemoteAdapterAddress(const std::string& value) = 0;
|
||||
virtual std::string getBluetoothAdapterAddress() const = 0;
|
||||
virtual void setBluetoothAdapterAddress(const std::string& value) = 0;
|
||||
virtual bool getWirelessProjectionEnabled() const = 0;
|
||||
virtual void setWirelessProjectionEnabled(bool value) = 0;
|
||||
|
||||
virtual bool musicAudioChannelEnabled() const = 0;
|
||||
virtual void setMusicAudioChannelEnabled(bool value) = 0;
|
||||
virtual bool speechAudioChannelEnabled() const = 0;
|
||||
virtual void setSpeechAudioChannelEnabled(bool value) = 0;
|
||||
virtual bool guidanceAudioChannelEnabled() const = 0;
|
||||
virtual void setGuidanceAudioChannelEnabled(bool value) = 0;
|
||||
virtual bool systemAudioChannelEnabled() const = 0;
|
||||
virtual void setSystemAudioChannelEnabled(bool value) = 0;
|
||||
virtual bool telephonyAudioChannelEnabled() const = 0;
|
||||
virtual void setTelephonyAudioChannelEnabled(bool value) = 0;
|
||||
virtual AudioOutputBackendType getAudioOutputBackendType() const = 0;
|
||||
virtual void setAudioOutputBackendType(AudioOutputBackendType value) = 0;
|
||||
};
|
||||
|
@ -34,8 +34,7 @@ class DummyBluetoothDevice: public IBluetoothDevice
|
||||
public:
|
||||
void stop() override;
|
||||
bool isPaired(const std::string& address) const override;
|
||||
void pair(const std::string& address, PairingPromise::Pointer promise) override;
|
||||
std::string getLocalAddress() const override;
|
||||
std::string getAdapterAddress() const override;
|
||||
bool isAvailable() const override;
|
||||
};
|
||||
|
||||
|
@ -37,8 +37,7 @@ public:
|
||||
|
||||
virtual void stop() = 0;
|
||||
virtual bool isPaired(const std::string& address) const = 0;
|
||||
virtual void pair(const std::string& address, PairingPromise::Pointer promise) = 0;
|
||||
virtual std::string getLocalAddress() const = 0;
|
||||
virtual std::string getAdapterAddress() const = 0;
|
||||
virtual bool isAvailable() const = 0;
|
||||
};
|
||||
|
||||
|
@ -37,7 +37,7 @@ class IInputDevice
|
||||
{
|
||||
public:
|
||||
typedef std::shared_ptr<IInputDevice> Pointer;
|
||||
typedef std::vector<aasdk::proto::enums::ButtonCode::Enum> ButtonCodes;
|
||||
typedef std::vector<aap_protobuf::service::media::sink::message::KeyCode> ButtonCodes;
|
||||
|
||||
virtual ~IInputDevice() = default;
|
||||
virtual void start(IInputDeviceEventHandler& eventHandler) = 0;
|
||||
|
@ -20,9 +20,10 @@
|
||||
|
||||
#include <memory>
|
||||
#include <QRect>
|
||||
#include <aasdk_proto/VideoFPSEnum.pb.h>
|
||||
#include <aasdk_proto/VideoResolutionEnum.pb.h>
|
||||
#include <aasdk/Common/Data.hpp>
|
||||
#include <aasdk/Messenger/Timestamp.hpp>
|
||||
#include <aap_protobuf/service/media/sink/message/VideoFrameRateType.pb.h>
|
||||
#include <aap_protobuf/service/media/sink/message/VideoCodecResolutionType.pb.h>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
@ -43,13 +44,14 @@ public:
|
||||
|
||||
virtual bool open() = 0;
|
||||
virtual bool init() = 0;
|
||||
virtual void write(uint64_t timestamp, const aasdk::common::DataConstBuffer& buffer) = 0;
|
||||
virtual void write(aasdk::messenger::Timestamp::ValueType timestamp, const aasdk::common::DataConstBuffer& buffer) = 0;
|
||||
virtual void stop() = 0;
|
||||
|
||||
virtual aasdk::proto::enums::VideoFPS::Enum getVideoFPS() const = 0;
|
||||
virtual aasdk::proto::enums::VideoResolution::Enum getVideoResolution() const = 0;
|
||||
virtual aap_protobuf::service::media::sink::message::VideoFrameRateType getVideoFPS() const = 0;
|
||||
virtual aap_protobuf::service::media::sink::message::VideoCodecResolutionType getVideoResolution() const = 0;
|
||||
virtual size_t getScreenDPI() const = 0;
|
||||
virtual QRect getVideoMargins() const = 0;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -18,8 +18,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aasdk_proto/ButtonCodeEnum.pb.h>
|
||||
#include <aasdk_proto/TouchActionEnum.pb.h>
|
||||
#include <aap_protobuf/service/media/sink/message/KeyCode.pb.h>
|
||||
#include <aap_protobuf/service/inputsource/message/PointerAction.pb.h>
|
||||
#include <aasdk/IO/Promise.hpp>
|
||||
|
||||
namespace f1x
|
||||
@ -49,12 +49,12 @@ struct ButtonEvent
|
||||
{
|
||||
ButtonEventType type;
|
||||
WheelDirection wheelDirection;
|
||||
aasdk::proto::enums::ButtonCode::Enum code;
|
||||
aap_protobuf::service::media::sink::message::KeyCode code;
|
||||
};
|
||||
|
||||
struct TouchEvent
|
||||
{
|
||||
aasdk::proto::enums::TouchAction::Enum type;
|
||||
aap_protobuf::service::inputsource::message::PointerAction type;
|
||||
uint32_t x;
|
||||
uint32_t y;
|
||||
uint32_t pointerId;
|
||||
|
@ -23,13 +23,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace projection
|
||||
namespace f1x::openauto::autoapp::projection
|
||||
{
|
||||
|
||||
class LocalBluetoothDevice: public QObject, public IBluetoothDevice
|
||||
@ -37,25 +31,15 @@ class LocalBluetoothDevice: public QObject, public IBluetoothDevice
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LocalBluetoothDevice();
|
||||
LocalBluetoothDevice(const QString &adapterAddress = QString(), QObject *parent = nullptr);
|
||||
|
||||
void stop() override;
|
||||
bool isPaired(const std::string& address) const override;
|
||||
void pair(const std::string& address, PairingPromise::Pointer promise) override;
|
||||
std::string getLocalAddress() const override;
|
||||
std::string getAdapterAddress() const override;
|
||||
bool isAvailable() const override;
|
||||
|
||||
signals:
|
||||
void startPairing(const QString& address, PairingPromise::Pointer promise);
|
||||
|
||||
private slots:
|
||||
void createBluetoothLocalDevice();
|
||||
void onStartPairing(const QString& address, PairingPromise::Pointer promise);
|
||||
void onPairingDisplayConfirmation(const QBluetoothAddress &address, QString pin);
|
||||
void onPairingDisplayPinCode(const QBluetoothAddress &address, QString pin);
|
||||
void onPairingFinished(const QBluetoothAddress &address, QBluetoothLocalDevice::Pairing pairing);
|
||||
void onError(QBluetoothLocalDevice::Error error);
|
||||
void onHostModeStateChanged(QBluetoothLocalDevice::HostMode state);
|
||||
void createBluetoothLocalDevice(const QString &adapterAddress);
|
||||
|
||||
private:
|
||||
mutable std::mutex mutex_;
|
||||
@ -65,10 +49,9 @@ private:
|
||||
QBluetoothServiceInfo serviceInfo_;
|
||||
std::unique_ptr<QBluetoothServer> rfcommServer_;
|
||||
|
||||
void onClientConnected();
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -35,8 +35,8 @@ class VideoOutput: public IVideoOutput
|
||||
public:
|
||||
VideoOutput(configuration::IConfiguration::Pointer configuration);
|
||||
|
||||
aasdk::proto::enums::VideoFPS::Enum getVideoFPS() const override;
|
||||
aasdk::proto::enums::VideoResolution::Enum getVideoResolution() const override;
|
||||
aap_protobuf::service::media::sink::message::VideoFrameRateType getVideoFPS() const override;
|
||||
aap_protobuf::service::media::sink::message::VideoCodecResolutionType getVideoResolution() const override;
|
||||
size_t getScreenDPI() const override;
|
||||
QRect getVideoMargins() const override;
|
||||
|
||||
|
@ -22,11 +22,15 @@
|
||||
#include <aasdk/Transport/ITransport.hpp>
|
||||
#include <aasdk/Channel/Control/IControlServiceChannel.hpp>
|
||||
#include <aasdk/Channel/Control/IControlServiceChannelEventHandler.hpp>
|
||||
#include <aasdk/Channel/AV/VideoServiceChannel.hpp>
|
||||
#include <aasdk/Channel/MediaSink/Video/Channel/VideoChannel.hpp>
|
||||
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntity.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/IPinger.hpp>
|
||||
#include <Transport/ITransport.hpp>
|
||||
#include <aap_protobuf/service/control/message/AudioFocusRequestType.pb.h>
|
||||
#include <aap_protobuf/service/control/message/AudioFocusStateType.pb.h>
|
||||
#include <aap_protobuf/service/control/message/NavFocusType.pb.h>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
@ -53,17 +57,19 @@ public:
|
||||
void stop() override;
|
||||
void pause() override;
|
||||
void resume() override;
|
||||
void onVersionResponse(uint16_t majorCode, uint16_t minorCode, aasdk::proto::enums::VersionResponseStatus::Enum status) override;
|
||||
// TODO: on channel open request... on channel close... on navigation focus, on voice session notification, on user switch, on call availability, on service disc update, on battery status, on car connected devices
|
||||
void onVersionResponse(uint16_t majorCode, uint16_t minorCode, aap_protobuf::shared::MessageStatus status) override;
|
||||
void onHandshake(const aasdk::common::DataConstBuffer& payload) override;
|
||||
void onServiceDiscoveryRequest(const aasdk::proto::messages::ServiceDiscoveryRequest& request) override;
|
||||
void onAudioFocusRequest(const aasdk::proto::messages::AudioFocusRequest& request) override;
|
||||
void onShutdownRequest(const aasdk::proto::messages::ShutdownRequest& request) override;
|
||||
void onShutdownResponse(const aasdk::proto::messages::ShutdownResponse& response) override;
|
||||
void onNavigationFocusRequest(const aasdk::proto::messages::NavigationFocusRequest& request) override;
|
||||
void onServiceDiscoveryRequest(const aap_protobuf::service::control::message::ServiceDiscoveryRequest& request) override;
|
||||
void onAudioFocusRequest(const aap_protobuf::service::control::message::AudioFocusRequest& request) override;
|
||||
void onByeByeRequest(const aap_protobuf::service::control::message::ByeByeRequest& request) override;
|
||||
void onByeByeResponse(const aap_protobuf::service::control::message::ByeByeResponse& response) override;
|
||||
void onNavigationFocusRequest(const aap_protobuf::service::control::message::NavFocusRequestNotification& request) override;
|
||||
void onVoiceSessionRequest(const aap_protobuf::service::control::message::VoiceSessionNotification &request) override;
|
||||
void onBatteryStatusNotification(const aap_protobuf::service::control::message::BatteryStatusNotification ¬ification) override;
|
||||
void onPingResponse(const aap_protobuf::service::control::message::PingResponse& response) override;
|
||||
void onPingRequest(const aap_protobuf::service::control::message::PingRequest& request) override;
|
||||
void onChannelError(const aasdk::error::Error& e) override;
|
||||
void onPingRequest(const aasdk::proto::messages::PingRequest& request) override;
|
||||
void onPingResponse(const aasdk::proto::messages::PingResponse& response) override;
|
||||
void onVoiceSessionRequest(const aasdk::proto::messages::VoiceSessionRequest& request) override;
|
||||
|
||||
private:
|
||||
using std::enable_shared_from_this<AndroidAutoEntity>::shared_from_this;
|
||||
|
@ -1,67 +0,0 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aasdk/Channel/AV/AVInputServiceChannel.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/IAudioInput.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace service
|
||||
{
|
||||
|
||||
class AudioInputService: public aasdk::channel::av::IAVInputServiceChannelEventHandler, public IService, public std::enable_shared_from_this<AudioInputService>
|
||||
{
|
||||
public:
|
||||
typedef std::shared_ptr<AudioInputService> Pointer;
|
||||
|
||||
AudioInputService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IAudioInput::Pointer audioInput);
|
||||
|
||||
void start() override;
|
||||
void stop() override;
|
||||
void pause() override;
|
||||
void resume() override;
|
||||
void fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response) override;
|
||||
void onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request) override;
|
||||
void onAVChannelSetupRequest(const aasdk::proto::messages::AVChannelSetupRequest& request) override;
|
||||
void onAVInputOpenRequest(const aasdk::proto::messages::AVInputOpenRequest& request) override;
|
||||
void onAVMediaAckIndication(const aasdk::proto::messages::AVMediaAckIndication& indication) override;
|
||||
void onChannelError(const aasdk::error::Error& e) override;
|
||||
|
||||
private:
|
||||
using std::enable_shared_from_this<AudioInputService>::shared_from_this;
|
||||
void onAudioInputOpenSucceed();
|
||||
void onAudioInputDataReady(aasdk::common::Data data);
|
||||
void readAudioInput();
|
||||
|
||||
boost::asio::io_service::strand strand_;
|
||||
aasdk::channel::av::AVInputServiceChannel::Pointer channel_;
|
||||
projection::IAudioInput::Pointer audioInput_;
|
||||
int32_t session_;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aasdk/Channel/AV/IAudioServiceChannel.hpp>
|
||||
#include <aasdk/Channel/AV/IAudioServiceChannelEventHandler.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/IAudioOutput.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace service
|
||||
{
|
||||
|
||||
class AudioService: public aasdk::channel::av::IAudioServiceChannelEventHandler, public IService, public std::enable_shared_from_this<AudioService>
|
||||
{
|
||||
public:
|
||||
typedef std::shared_ptr<AudioService> Pointer;
|
||||
|
||||
AudioService(boost::asio::io_service& ioService, aasdk::channel::av::IAudioServiceChannel::Pointer channel, projection::IAudioOutput::Pointer audioOutput);
|
||||
|
||||
void start() override;
|
||||
void stop() override;
|
||||
void pause() override;
|
||||
void resume() override;
|
||||
void fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response) override;
|
||||
void onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request) override;
|
||||
void onAVChannelSetupRequest(const aasdk::proto::messages::AVChannelSetupRequest& request) override;
|
||||
void onAVChannelStartIndication(const aasdk::proto::messages::AVChannelStartIndication& indication) override;
|
||||
void onAVChannelStopIndication(const aasdk::proto::messages::AVChannelStopIndication& indication) override;
|
||||
void onAVMediaWithTimestampIndication(aasdk::messenger::Timestamp::ValueType timestamp, const aasdk::common::DataConstBuffer& buffer) override;
|
||||
void onAVMediaIndication(const aasdk::common::DataConstBuffer& buffer) override;
|
||||
void onChannelError(const aasdk::error::Error& e) override;
|
||||
|
||||
protected:
|
||||
using std::enable_shared_from_this<AudioService>::shared_from_this;
|
||||
|
||||
boost::asio::io_service::strand strand_;
|
||||
aasdk::channel::av::IAudioServiceChannel::Pointer channel_;
|
||||
projection::IAudioOutput::Pointer audioOutput_;
|
||||
int32_t session_;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aasdk/Channel/Bluetooth/BluetoothService.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/IBluetoothDevice.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
||||
|
||||
namespace f1x {
|
||||
namespace openauto {
|
||||
namespace autoapp {
|
||||
namespace service {
|
||||
namespace bluetooth {
|
||||
|
||||
class BluetoothService
|
||||
: public aasdk::channel::bluetooth::IBluetoothServiceEventHandler,
|
||||
public IService,
|
||||
public std::enable_shared_from_this<BluetoothService> {
|
||||
public:
|
||||
BluetoothService(boost::asio::io_service &ioService,
|
||||
aasdk::messenger::IMessenger::Pointer messenger,
|
||||
projection::IBluetoothDevice::Pointer bluetoothDevice);
|
||||
|
||||
void start() override;
|
||||
void stop() override;
|
||||
void pause() override;
|
||||
void resume() override;
|
||||
void fillFeatures(aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) override;
|
||||
|
||||
void onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) override;
|
||||
|
||||
void onBluetoothPairingRequest(
|
||||
const aap_protobuf::service::bluetooth::message::BluetoothPairingRequest &request) override;
|
||||
|
||||
void onBluetoothAuthenticationResult(const aap_protobuf::service::bluetooth::message::BluetoothAuthenticationResult &request) override;
|
||||
|
||||
void onChannelError(const aasdk::error::Error &e) override;
|
||||
|
||||
|
||||
private:
|
||||
using std::enable_shared_from_this<BluetoothService>::shared_from_this;
|
||||
|
||||
void sendBluetoothAuthenticationData();
|
||||
|
||||
boost::asio::io_service::strand strand_;
|
||||
aasdk::channel::bluetooth::BluetoothService::Pointer channel_;
|
||||
projection::IBluetoothDevice::Pointer bluetoothDevice_;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aasdk/Channel/Bluetooth/BluetoothServiceChannel.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/IBluetoothDevice.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace service
|
||||
{
|
||||
|
||||
class BluetoothService: public aasdk::channel::bluetooth::IBluetoothServiceChannelEventHandler, public IService, public std::enable_shared_from_this<BluetoothService>
|
||||
{
|
||||
public:
|
||||
BluetoothService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IBluetoothDevice::Pointer bluetoothDevice);
|
||||
void start() override;
|
||||
void stop() override;
|
||||
void pause() override;
|
||||
void resume() override;
|
||||
void fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response) override;
|
||||
void onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request) override;
|
||||
void onBluetoothPairingRequest(const aasdk::proto::messages::BluetoothPairingRequest& request) override;
|
||||
void onChannelError(const aasdk::error::Error& e) override;
|
||||
|
||||
private:
|
||||
using std::enable_shared_from_this<BluetoothService>::shared_from_this;
|
||||
|
||||
boost::asio::io_service::strand strand_;
|
||||
aasdk::channel::bluetooth::BluetoothServiceChannel::Pointer channel_;
|
||||
projection::IBluetoothDevice::Pointer bluetoothDevice_;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aasdk/Channel/GenericNotification/GenericNotificationService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <aasdk/Messenger/IMessenger.hpp>
|
||||
|
||||
namespace f1x {
|
||||
namespace openauto {
|
||||
namespace autoapp {
|
||||
namespace service {
|
||||
namespace genericnotification {
|
||||
|
||||
class GenericNotificationService :
|
||||
public aasdk::channel::genericnotification::IGenericNotificationServiceEventHandler,
|
||||
public IService,
|
||||
public std::enable_shared_from_this<GenericNotificationService> {
|
||||
public:
|
||||
GenericNotificationService(boost::asio::io_service &ioService, aasdk::messenger::IMessenger::Pointer messenger);
|
||||
|
||||
void start() override;
|
||||
void stop() override;
|
||||
void pause() override;
|
||||
void resume() override;
|
||||
void fillFeatures(aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) override;
|
||||
|
||||
void onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) override;
|
||||
|
||||
void onChannelError(const aasdk::error::Error &e) override;
|
||||
|
||||
|
||||
private:
|
||||
using std::enable_shared_from_this<GenericNotificationService>::shared_from_this;
|
||||
boost::asio::deadline_timer timer_;
|
||||
boost::asio::io_service::strand strand_;
|
||||
aasdk::channel::genericnotification::GenericNotificationService::Pointer channel_;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -20,34 +20,33 @@
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <aasdk_proto/ServiceDiscoveryResponseMessage.pb.h>
|
||||
#include <f1x/openauto/Common/Log.hpp>
|
||||
#include <aap_protobuf/service/control/message/ServiceDiscoveryResponse.pb.h>
|
||||
#include <aap_protobuf/shared/MessageStatus.pb.h>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace service
|
||||
{
|
||||
|
||||
class IService
|
||||
{
|
||||
public:
|
||||
namespace f1x::openauto::autoapp::service {
|
||||
|
||||
class IService {
|
||||
public:
|
||||
typedef std::shared_ptr<IService> Pointer;
|
||||
|
||||
virtual ~IService() = default;
|
||||
|
||||
virtual void start() = 0;
|
||||
|
||||
virtual void stop() = 0;
|
||||
|
||||
virtual void pause() = 0;
|
||||
|
||||
virtual void resume() = 0;
|
||||
virtual void fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response) = 0;
|
||||
};
|
||||
|
||||
typedef std::vector<IService::Pointer> ServiceList;
|
||||
virtual void fillFeatures(aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) = 0;
|
||||
};
|
||||
|
||||
typedef std::vector<IService::Pointer> ServiceList;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,67 +0,0 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aasdk_proto/ButtonCodeEnum.pb.h>
|
||||
#include <aasdk/Channel/Input/InputServiceChannel.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/IInputDevice.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/IInputDeviceEventHandler.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace service
|
||||
{
|
||||
|
||||
class InputService:
|
||||
public aasdk::channel::input::IInputServiceChannelEventHandler,
|
||||
public IService,
|
||||
public projection::IInputDeviceEventHandler,
|
||||
public std::enable_shared_from_this<InputService>
|
||||
{
|
||||
public:
|
||||
InputService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IInputDevice::Pointer inputDevice);
|
||||
|
||||
void start() override;
|
||||
void stop() override;
|
||||
void pause() override;
|
||||
void resume() override;
|
||||
void fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response) override;
|
||||
void onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request) override;
|
||||
void onBindingRequest(const aasdk::proto::messages::BindingRequest& request) override;
|
||||
void onChannelError(const aasdk::error::Error& e) override;
|
||||
void onButtonEvent(const projection::ButtonEvent& event) override;
|
||||
void onTouchEvent(const projection::TouchEvent& event) override;
|
||||
|
||||
private:
|
||||
using std::enable_shared_from_this<InputService>::shared_from_this;
|
||||
|
||||
boost::asio::io_service::strand strand_;
|
||||
aasdk::channel::input::InputServiceChannel::Pointer channel_;
|
||||
projection::IInputDevice::Pointer inputDevice_;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aap_protobuf/service/media/sink/message/KeyCode.pb.h>
|
||||
#include <aasdk/Channel/InputSource/InputSourceService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/IInputDevice.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/IInputDeviceEventHandler.hpp>
|
||||
|
||||
namespace f1x {
|
||||
namespace openauto {
|
||||
namespace autoapp {
|
||||
namespace service {
|
||||
namespace inputsource {
|
||||
|
||||
class InputSourceService :
|
||||
public aasdk::channel::inputsource::IInputSourceServiceEventHandler,
|
||||
public IService,
|
||||
public projection::IInputDeviceEventHandler,
|
||||
public std::enable_shared_from_this<InputSourceService> {
|
||||
public:
|
||||
InputSourceService(boost::asio::io_service &ioService, aasdk::messenger::IMessenger::Pointer messenger,
|
||||
projection::IInputDevice::Pointer inputDevice);
|
||||
|
||||
void start() override;
|
||||
void stop() override;
|
||||
void pause() override;
|
||||
void resume() override;
|
||||
void fillFeatures(aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) override;
|
||||
|
||||
|
||||
void onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) override;
|
||||
|
||||
void onKeyBindingRequest(const aap_protobuf::service::media::sink::message::KeyBindingRequest &request) override;
|
||||
|
||||
void onChannelError(const aasdk::error::Error &e) override;
|
||||
|
||||
void onButtonEvent(const projection::ButtonEvent &event) override;
|
||||
|
||||
void onTouchEvent(const projection::TouchEvent &event) override;
|
||||
|
||||
private:
|
||||
using std::enable_shared_from_this<InputSourceService>::shared_from_this;
|
||||
|
||||
boost::asio::io_service::strand strand_;
|
||||
aasdk::channel::inputsource::InputSourceService::Pointer channel_;
|
||||
projection::IInputDevice::Pointer inputDevice_;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aasdk/Channel/MediaBrowser/MediaBrowserService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <aasdk/Messenger/IMessenger.hpp>
|
||||
|
||||
namespace f1x {
|
||||
namespace openauto {
|
||||
namespace autoapp {
|
||||
namespace service {
|
||||
namespace mediabrowser {
|
||||
|
||||
class MediaBrowserService :
|
||||
public aasdk::channel::mediabrowser::IMediaBrowserServiceEventHandler,
|
||||
public IService,
|
||||
public std::enable_shared_from_this<MediaBrowserService> {
|
||||
public:
|
||||
MediaBrowserService(boost::asio::io_service &ioService, aasdk::messenger::IMessenger::Pointer messenger);
|
||||
|
||||
void start() override;
|
||||
void stop() override;
|
||||
void pause() override;
|
||||
void resume() override;
|
||||
void fillFeatures(aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) override;
|
||||
|
||||
void onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) override;
|
||||
|
||||
void onChannelError(const aasdk::error::Error &e) override;
|
||||
|
||||
|
||||
private:
|
||||
using std::enable_shared_from_this<MediaBrowserService>::shared_from_this;
|
||||
boost::asio::deadline_timer timer_;
|
||||
boost::asio::io_service::strand strand_;
|
||||
aasdk::channel::mediabrowser::MediaBrowserService::Pointer channel_;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aasdk/Channel/MediaPlaybackStatus/MediaPlaybackStatusService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <aasdk/Messenger/IMessenger.hpp>
|
||||
|
||||
namespace f1x {
|
||||
namespace openauto {
|
||||
namespace autoapp {
|
||||
namespace service {
|
||||
namespace mediaplaybackstatus {
|
||||
|
||||
class MediaPlaybackStatusService :
|
||||
public aasdk::channel::mediaplaybackstatus::IMediaPlaybackStatusServiceEventHandler,
|
||||
public IService,
|
||||
public std::enable_shared_from_this<MediaPlaybackStatusService> {
|
||||
public:
|
||||
MediaPlaybackStatusService(boost::asio::io_service &ioService, aasdk::messenger::IMessenger::Pointer messenger);
|
||||
|
||||
void start() override;
|
||||
void stop() override;
|
||||
void pause() override;
|
||||
void resume() override;
|
||||
void fillFeatures(aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) override;
|
||||
|
||||
void onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) override;
|
||||
|
||||
void onChannelError(const aasdk::error::Error &e) override;
|
||||
|
||||
|
||||
private:
|
||||
using std::enable_shared_from_this<MediaPlaybackStatusService>::shared_from_this;
|
||||
boost::asio::deadline_timer timer_;
|
||||
boost::asio::io_service::strand strand_;
|
||||
aasdk::channel::mediaplaybackstatus::MediaPlaybackStatusService::Pointer channel_;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <aasdk/Messenger/IMessenger.hpp>
|
||||
#include <aasdk/Channel/MediaSink/Audio/IAudioMediaSinkService.hpp>
|
||||
#include <aasdk/Channel/MediaSink/Audio/IAudioMediaSinkServiceEventHandler.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/IAudioOutput.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
||||
|
||||
namespace f1x {
|
||||
namespace openauto {
|
||||
namespace autoapp {
|
||||
namespace service {
|
||||
namespace mediasink {
|
||||
class AudioMediaSinkService :
|
||||
public aasdk::channel::mediasink::audio::IAudioMediaSinkServiceEventHandler,
|
||||
public IService,
|
||||
public std::enable_shared_from_this<AudioMediaSinkService> {
|
||||
public:
|
||||
typedef std::shared_ptr<AudioMediaSinkService> Pointer;
|
||||
|
||||
// General Constructor
|
||||
AudioMediaSinkService(boost::asio::io_service& ioService,
|
||||
aasdk::channel::mediasink::audio::IAudioMediaSinkService::Pointer channel,
|
||||
projection::IAudioOutput::Pointer audioOutput);
|
||||
|
||||
void start() override;
|
||||
void stop() override;
|
||||
void pause() override;
|
||||
void resume() override;
|
||||
void fillFeatures(aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) override;
|
||||
|
||||
void onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) override;
|
||||
|
||||
void onMediaChannelSetupRequest(
|
||||
const aap_protobuf::service::media::shared::message::Setup &request) override;
|
||||
|
||||
void onMediaChannelStartIndication(
|
||||
const aap_protobuf::service::media::shared::message::Start &indication) override;
|
||||
|
||||
void onMediaChannelStopIndication(
|
||||
const aap_protobuf::service::media::shared::message::Stop &indication) override;
|
||||
|
||||
void onMediaWithTimestampIndication(aasdk::messenger::Timestamp::ValueType timestamp,
|
||||
const aasdk::common::DataConstBuffer &buffer) override;
|
||||
|
||||
void onMediaIndication(const aasdk::common::DataConstBuffer &buffer) override;
|
||||
|
||||
void onChannelError(const aasdk::error::Error &e) override;
|
||||
|
||||
protected:
|
||||
using std::enable_shared_from_this<AudioMediaSinkService>::shared_from_this;
|
||||
boost::asio::io_service::strand strand_;
|
||||
aasdk::channel::mediasink::audio::IAudioMediaSinkService::Pointer channel_;
|
||||
projection::IAudioOutput::Pointer audioOutput_;
|
||||
int32_t session_;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -18,25 +18,24 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aasdk/Messenger/IMessenger.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/AudioService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/MediaSink/AudioMediaSinkService.hpp>
|
||||
#include <aasdk/Channel/MediaSink/Audio/Channel/GuidanceAudioChannel.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace service
|
||||
{
|
||||
namespace f1x {
|
||||
namespace openauto {
|
||||
namespace autoapp {
|
||||
namespace service {
|
||||
namespace mediasink {
|
||||
class GuidanceAudioService : public AudioMediaSinkService {
|
||||
public:
|
||||
GuidanceAudioService(boost::asio::io_service &ioService,
|
||||
aasdk::messenger::IMessenger::Pointer messenger,
|
||||
projection::IAudioOutput::Pointer audioOutput);
|
||||
|
||||
class SystemAudioService: public AudioService
|
||||
{
|
||||
public:
|
||||
SystemAudioService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IAudioOutput::Pointer audioOutput);
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -18,25 +18,24 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aasdk/Messenger/IMessenger.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/AudioService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/MediaSink/AudioMediaSinkService.hpp>
|
||||
#include <aasdk/Channel/MediaSink/Audio/Channel/MediaAudioChannel.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace service
|
||||
{
|
||||
|
||||
class MediaAudioService: public AudioService
|
||||
{
|
||||
public:
|
||||
MediaAudioService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IAudioOutput::Pointer audioOutput);
|
||||
};
|
||||
namespace f1x {
|
||||
namespace openauto {
|
||||
namespace autoapp {
|
||||
namespace service {
|
||||
namespace mediasink {
|
||||
class MediaAudioService : public AudioMediaSinkService {
|
||||
public:
|
||||
MediaAudioService(boost::asio::io_service &ioService,
|
||||
aasdk::messenger::IMessenger::Pointer messenger,
|
||||
projection::IAudioOutput::Pointer audioOutput);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <f1x/openauto/autoapp/Service/MediaSink/AudioMediaSinkService.hpp>
|
||||
#include <aasdk/Channel/MediaSink/Audio/Channel/SystemAudioChannel.hpp>
|
||||
|
||||
namespace f1x {
|
||||
namespace openauto {
|
||||
namespace autoapp {
|
||||
namespace service {
|
||||
namespace mediasink {
|
||||
class SystemAudioService : public AudioMediaSinkService {
|
||||
public:
|
||||
SystemAudioService(boost::asio::io_service &ioService,
|
||||
aasdk::messenger::IMessenger::Pointer messenger,
|
||||
projection::IAudioOutput::Pointer audioOutput);
|
||||
|
||||
protected:
|
||||
projection::IAudioOutput::Pointer audioOutput_;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <f1x/openauto/autoapp/Service/MediaSink/AudioMediaSinkService.hpp>
|
||||
#include <aasdk/Channel/MediaSink/Audio/Channel/TelephonyAudioChannel.hpp>
|
||||
|
||||
|
||||
namespace f1x {
|
||||
namespace openauto {
|
||||
namespace autoapp {
|
||||
namespace service {
|
||||
namespace mediasink {
|
||||
class TelephonyAudioService : public AudioMediaSinkService {
|
||||
public:
|
||||
TelephonyAudioService(boost::asio::io_service &ioService,
|
||||
aasdk::messenger::IMessenger::Pointer messenger,
|
||||
projection::IAudioOutput::Pointer audioOutput);
|
||||
|
||||
protected:
|
||||
projection::IAudioOutput::Pointer audioOutput_;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aasdk/Messenger/IMessenger.hpp>
|
||||
#include <aasdk/Channel/MediaSink/Video/IVideoMediaSinkService.hpp>
|
||||
#include <aasdk/Channel/MediaSink/Video/IVideoMediaSinkServiceEventHandler.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/IVideoOutput.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
||||
|
||||
namespace f1x {
|
||||
namespace openauto {
|
||||
namespace autoapp {
|
||||
namespace service {
|
||||
namespace mediasink {
|
||||
|
||||
class VideoMediaSinkService :
|
||||
public aasdk::channel::mediasink::video::IVideoMediaSinkServiceEventHandler,
|
||||
public IService,
|
||||
public std::enable_shared_from_this<VideoMediaSinkService> {
|
||||
public:
|
||||
typedef std::shared_ptr<VideoMediaSinkService> Pointer;
|
||||
|
||||
// General Constructor
|
||||
VideoMediaSinkService(boost::asio::io_service& ioService,
|
||||
aasdk::channel::mediasink::video::IVideoMediaSinkService::Pointer channel,
|
||||
projection::IVideoOutput::Pointer videoOutput);
|
||||
|
||||
void start() override;
|
||||
void stop() override;
|
||||
void pause() override;
|
||||
void resume() override;
|
||||
void fillFeatures(aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) override;
|
||||
|
||||
void onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) override;
|
||||
|
||||
void onMediaChannelSetupRequest(
|
||||
const aap_protobuf::service::media::shared::message::Setup &request) override;
|
||||
|
||||
void onMediaChannelStartIndication(
|
||||
const aap_protobuf::service::media::shared::message::Start &indication) override;
|
||||
|
||||
void onMediaChannelStopIndication(
|
||||
const aap_protobuf::service::media::shared::message::Stop &indication) override;
|
||||
|
||||
void onMediaWithTimestampIndication(aasdk::messenger::Timestamp::ValueType timestamp,
|
||||
const aasdk::common::DataConstBuffer &buffer) override;
|
||||
|
||||
void onMediaIndication(const aasdk::common::DataConstBuffer &buffer) override;
|
||||
|
||||
void onChannelError(const aasdk::error::Error &e) override;
|
||||
|
||||
void onVideoFocusRequest(const aap_protobuf::service::media::video::message::VideoFocusRequestNotification &request) override;
|
||||
void sendVideoFocusIndication();
|
||||
protected:
|
||||
using std::enable_shared_from_this<VideoMediaSinkService>::shared_from_this;
|
||||
boost::asio::io_service::strand strand_;
|
||||
aasdk::channel::mediasink::video::IVideoMediaSinkService::Pointer channel_;
|
||||
projection::IVideoOutput::Pointer videoOutput_;
|
||||
int32_t session_;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -18,25 +18,27 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aasdk/Messenger/IMessenger.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/AudioService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/MediaSink/VideoMediaSinkService.hpp>
|
||||
#include <aasdk/Channel/MediaSink/Video/Channel/VideoChannel.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace service
|
||||
{
|
||||
|
||||
class SpeechAudioService: public AudioService
|
||||
{
|
||||
public:
|
||||
SpeechAudioService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IAudioOutput::Pointer audioOutput);
|
||||
};
|
||||
namespace f1x {
|
||||
namespace openauto {
|
||||
namespace autoapp {
|
||||
namespace service {
|
||||
namespace mediasink {
|
||||
class VideoService : public VideoMediaSinkService {
|
||||
public:
|
||||
VideoService(boost::asio::io_service &ioService,
|
||||
aasdk::messenger::IMessenger::Pointer messenger,
|
||||
projection::IVideoOutput::Pointer videoOutput);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
protected:
|
||||
projection::IVideoOutput::Pointer videoOutput;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aasdk/Channel/MediaSource/IMediaSourceService.hpp>
|
||||
#include <aasdk/Channel/MediaSource/MediaSourceService.hpp>
|
||||
#include <aasdk/Channel/MediaSource/IMediaSourceServiceEventHandler.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/IAudioInput.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace service
|
||||
{
|
||||
namespace mediasource {
|
||||
|
||||
|
||||
class MediaSourceService
|
||||
: public aasdk::channel::mediasource::IMediaSourceServiceEventHandler,
|
||||
public IService,
|
||||
public std::enable_shared_from_this<MediaSourceService> {
|
||||
public:
|
||||
typedef std::shared_ptr<MediaSourceService> Pointer;
|
||||
|
||||
// General Constructor
|
||||
MediaSourceService(boost::asio::io_service& ioService,
|
||||
aasdk::channel::mediasource::IMediaSourceService::Pointer channel, projection::IAudioInput::Pointer audioInput);
|
||||
|
||||
void start() override;
|
||||
|
||||
void stop() override;
|
||||
|
||||
void pause() override;
|
||||
|
||||
void resume() override;
|
||||
|
||||
void fillFeatures(
|
||||
aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) override;
|
||||
|
||||
void onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) override;
|
||||
|
||||
void onMediaChannelSetupRequest(
|
||||
const aap_protobuf::service::media::shared::message::Setup &request) override;
|
||||
|
||||
void onMediaSourceOpenRequest(
|
||||
const aap_protobuf::service::media::source::message::MicrophoneRequest &request) override;
|
||||
|
||||
void onMediaChannelAckIndication(
|
||||
const aap_protobuf::service::media::source::message::Ack &indication) override;
|
||||
|
||||
void onChannelError(const aasdk::error::Error &e) override;
|
||||
|
||||
protected:
|
||||
using std::enable_shared_from_this<MediaSourceService>::shared_from_this;
|
||||
|
||||
void onMediaSourceOpenSuccess();
|
||||
|
||||
void onMediaSourceDataReady(aasdk::common::Data data);
|
||||
|
||||
void readMediaSource();
|
||||
|
||||
boost::asio::io_service::strand strand_;
|
||||
aasdk::channel::mediasource::IMediaSourceService::Pointer channel_;
|
||||
projection::IAudioInput::Pointer audioInput_;
|
||||
int32_t session_;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <f1x/openauto/autoapp/Service/MediaSource/MediaSourceService.hpp>
|
||||
#include <aasdk/Channel/MediaSource/Audio/MicrophoneAudioChannel.hpp>
|
||||
|
||||
|
||||
namespace f1x {
|
||||
namespace openauto {
|
||||
namespace autoapp {
|
||||
namespace service {
|
||||
namespace mediasource {
|
||||
class MicrophoneMediaSourceService : public MediaSourceService {
|
||||
public:
|
||||
MicrophoneMediaSourceService(boost::asio::io_service &ioService,
|
||||
aasdk::messenger::IMessenger::Pointer messenger,
|
||||
projection::IAudioInput::Pointer audioInput);
|
||||
|
||||
protected:
|
||||
projection::IAudioInput::Pointer audioInput_;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aasdk/Channel/NavigationStatus/NavigationStatusService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <aasdk/Messenger/IMessenger.hpp>
|
||||
|
||||
namespace f1x {
|
||||
namespace openauto {
|
||||
namespace autoapp {
|
||||
namespace service {
|
||||
namespace navigationstatus {
|
||||
|
||||
class NavigationStatusService :
|
||||
public aasdk::channel::navigationstatus::INavigationStatusServiceEventHandler,
|
||||
public IService,
|
||||
public std::enable_shared_from_this<NavigationStatusService> {
|
||||
public:
|
||||
NavigationStatusService(boost::asio::io_service &ioService, aasdk::messenger::IMessenger::Pointer messenger);
|
||||
|
||||
void start() override;
|
||||
void stop() override;
|
||||
void pause() override;
|
||||
void resume() override;
|
||||
void fillFeatures(aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) override;
|
||||
|
||||
void onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) override;
|
||||
|
||||
void onChannelError(const aasdk::error::Error &e) override;
|
||||
|
||||
void onStatusUpdate(const aap_protobuf::service::navigationstatus::message::NavigationStatus &navStatus) override;
|
||||
void onTurnEvent(const aap_protobuf::service::navigationstatus::message::NavigationNextTurnEvent &turnEvent) override;
|
||||
void onDistanceEvent(const aap_protobuf::service::navigationstatus::message::NavigationNextTurnDistanceEvent &distanceEvent) override;
|
||||
|
||||
private:
|
||||
using std::enable_shared_from_this<NavigationStatusService>::shared_from_this;
|
||||
boost::asio::deadline_timer timer_;
|
||||
boost::asio::io_service::strand strand_;
|
||||
aasdk::channel::navigationstatus::NavigationStatusService::Pointer channel_;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aasdk/Channel/PhoneStatus/PhoneStatusService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <aasdk/Messenger/IMessenger.hpp>
|
||||
|
||||
namespace f1x {
|
||||
namespace openauto {
|
||||
namespace autoapp {
|
||||
namespace service {
|
||||
namespace phonestatus {
|
||||
|
||||
class PhoneStatusService :
|
||||
public aasdk::channel::phonestatus::IPhoneStatusServiceEventHandler,
|
||||
public IService,
|
||||
public std::enable_shared_from_this<PhoneStatusService> {
|
||||
public:
|
||||
PhoneStatusService(boost::asio::io_service &ioService, aasdk::messenger::IMessenger::Pointer messenger);
|
||||
|
||||
void start() override;
|
||||
void stop() override;
|
||||
void pause() override;
|
||||
void resume() override;
|
||||
void fillFeatures(aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) override;
|
||||
|
||||
void onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) override;
|
||||
|
||||
void onChannelError(const aasdk::error::Error &e) override;
|
||||
|
||||
|
||||
private:
|
||||
using std::enable_shared_from_this<PhoneStatusService>::shared_from_this;
|
||||
boost::asio::deadline_timer timer_;
|
||||
boost::asio::io_service::strand strand_;
|
||||
aasdk::channel::phonestatus::PhoneStatusService::Pointer channel_;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
61
include/f1x/openauto/autoapp/Service/Radio/RadioService.hpp
Normal file
61
include/f1x/openauto/autoapp/Service/Radio/RadioService.hpp
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aasdk/Channel/Radio/RadioService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <aasdk/Messenger/IMessenger.hpp>
|
||||
|
||||
namespace f1x {
|
||||
namespace openauto {
|
||||
namespace autoapp {
|
||||
namespace service {
|
||||
namespace radio {
|
||||
|
||||
class RadioService :
|
||||
public aasdk::channel::radio::IRadioServiceEventHandler,
|
||||
public IService,
|
||||
public std::enable_shared_from_this<RadioService> {
|
||||
public:
|
||||
RadioService(boost::asio::io_service &ioService, aasdk::messenger::IMessenger::Pointer messenger);
|
||||
|
||||
void start() override;
|
||||
void stop() override;
|
||||
void pause() override;
|
||||
void resume() override;
|
||||
void fillFeatures(aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) override;
|
||||
|
||||
void onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) override;
|
||||
|
||||
void onChannelError(const aasdk::error::Error &e) override;
|
||||
|
||||
|
||||
private:
|
||||
using std::enable_shared_from_this<RadioService>::shared_from_this;
|
||||
boost::asio::deadline_timer timer_;
|
||||
boost::asio::io_service::strand strand_;
|
||||
aasdk::channel::radio::RadioService::Pointer channel_;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -19,52 +19,67 @@
|
||||
#pragma once
|
||||
|
||||
#include <gps.h>
|
||||
#include <aasdk/Channel/Sensor/SensorServiceChannel.hpp>
|
||||
#include <aap_protobuf/service/sensorsource/message/DrivingStatus.pb.h>
|
||||
#include <aap_protobuf/service/sensorsource/message/SensorType.pb.h>
|
||||
#include <aasdk/Channel/SensorSource/SensorSourceService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <aasdk/Messenger/IMessenger.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace service
|
||||
{
|
||||
|
||||
class SensorService: public aasdk::channel::sensor::ISensorServiceChannelEventHandler, public IService, public std::enable_shared_from_this<SensorService>
|
||||
{
|
||||
public:
|
||||
SensorService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger);
|
||||
namespace f1x::openauto::autoapp::service::sensor {
|
||||
class SensorService :
|
||||
public aasdk::channel::sensorsource::ISensorSourceServiceEventHandler,
|
||||
public IService,
|
||||
public std::enable_shared_from_this<SensorService> {
|
||||
public:
|
||||
SensorService(boost::asio::io_service &ioService,
|
||||
aasdk::messenger::IMessenger::Pointer messenger);
|
||||
|
||||
bool isNight = false;
|
||||
bool previous = false;
|
||||
bool stopPolling = false;
|
||||
|
||||
void start() override;
|
||||
void stop() override;
|
||||
void pause() override;
|
||||
void resume() override;
|
||||
void fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response) override;
|
||||
void onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request) override;
|
||||
void onSensorStartRequest(const aasdk::proto::messages::SensorStartRequestMessage& request) override;
|
||||
void onChannelError(const aasdk::error::Error& e) override;
|
||||
|
||||
private:
|
||||
void stop() override;
|
||||
|
||||
void pause() override;
|
||||
|
||||
void resume() override;
|
||||
|
||||
void fillFeatures(aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) override;
|
||||
|
||||
void onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) override;
|
||||
|
||||
void onSensorStartRequest(
|
||||
const aap_protobuf::service::sensorsource::message::SensorRequest &request) override;
|
||||
|
||||
void onChannelError(const aasdk::error::Error &e) override;
|
||||
|
||||
private:
|
||||
using std::enable_shared_from_this<SensorService>::shared_from_this;
|
||||
|
||||
void sendDrivingStatusUnrestricted();
|
||||
|
||||
void sendNightData();
|
||||
|
||||
void sendGPSLocationData();
|
||||
|
||||
bool is_file_exist(const char *filename);
|
||||
|
||||
void sensorPolling();
|
||||
|
||||
bool firstRun = true;
|
||||
|
||||
boost::asio::deadline_timer timer_;
|
||||
boost::asio::io_service::strand strand_;
|
||||
aasdk::channel::sensor::SensorServiceChannel::Pointer channel_;
|
||||
aasdk::channel::sensorsource::SensorSourceService::Pointer channel_;
|
||||
struct gps_data_t gpsData_;
|
||||
bool gpsEnabled_ = false;
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -18,33 +18,30 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aasdk/Channel/Bluetooth/BluetoothService.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/IBluetoothDevice.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace projection
|
||||
{
|
||||
namespace f1x::openauto::autoapp::service {
|
||||
|
||||
class RemoteBluetoothDevice: public IBluetoothDevice
|
||||
{
|
||||
public:
|
||||
RemoteBluetoothDevice(const std::string& address);
|
||||
class Service
|
||||
: public IService {
|
||||
public:
|
||||
Service(boost::asio::io_service &ioService);
|
||||
|
||||
void start() override;
|
||||
|
||||
void stop() override;
|
||||
bool isPaired(const std::string& address) const override;
|
||||
void pair(const std::string& address, PairingPromise::Pointer promise) override;
|
||||
std::string getLocalAddress() const override;
|
||||
bool isAvailable() const override;
|
||||
|
||||
private:
|
||||
std::string address_;
|
||||
};
|
||||
void pause() override;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
void resume() override;
|
||||
|
||||
void fillFeatures(aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) override;
|
||||
|
||||
private:
|
||||
|
||||
boost::asio::io_service::strand strand_;
|
||||
|
||||
};
|
||||
}
|
@ -21,32 +21,38 @@
|
||||
#include <f1x/openauto/autoapp/Service/IServiceFactory.hpp>
|
||||
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace service
|
||||
{
|
||||
namespace f1x {
|
||||
namespace openauto {
|
||||
namespace autoapp {
|
||||
namespace service {
|
||||
|
||||
class ServiceFactory: public IServiceFactory
|
||||
{
|
||||
public:
|
||||
ServiceFactory(boost::asio::io_service& ioService, configuration::IConfiguration::Pointer configuration);
|
||||
ServiceList create(aasdk::messenger::IMessenger::Pointer messenger) override;
|
||||
class ServiceFactory : public IServiceFactory {
|
||||
public:
|
||||
ServiceFactory(boost::asio::io_service &ioService, configuration::IConfiguration::Pointer configuration);
|
||||
ServiceList create(aasdk::messenger::IMessenger::Pointer messenger) override;
|
||||
|
||||
private:
|
||||
IService::Pointer createVideoService(aasdk::messenger::IMessenger::Pointer messenger);
|
||||
IService::Pointer createBluetoothService(aasdk::messenger::IMessenger::Pointer messenger);
|
||||
IService::Pointer createInputService(aasdk::messenger::IMessenger::Pointer messenger);
|
||||
void createAudioServices(ServiceList& serviceList, aasdk::messenger::IMessenger::Pointer messenger);
|
||||
private:
|
||||
IService::Pointer createBluetoothService(aasdk::messenger::IMessenger::Pointer messenger);
|
||||
IService::Pointer createGenericNotificationService(aasdk::messenger::IMessenger::Pointer messenger);
|
||||
IService::Pointer createInputService(aasdk::messenger::IMessenger::Pointer messenger);
|
||||
IService::Pointer createMediaBrowserService(aasdk::messenger::IMessenger::Pointer messenger);
|
||||
IService::Pointer createMediaPlaybackStatusService(aasdk::messenger::IMessenger::Pointer messenger);
|
||||
|
||||
boost::asio::io_service& ioService_;
|
||||
configuration::IConfiguration::Pointer configuration_;
|
||||
};
|
||||
void createMediaSinkServices(ServiceList &serviceList, aasdk::messenger::IMessenger::Pointer messenger);
|
||||
void createMediaSourceServices(ServiceList &serviceList, aasdk::messenger::IMessenger::Pointer messenger);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
IService::Pointer createNavigationStatusService(aasdk::messenger::IMessenger::Pointer messenger);
|
||||
IService::Pointer createPhoneStatusService(aasdk::messenger::IMessenger::Pointer messenger);
|
||||
IService::Pointer createRadioService(aasdk::messenger::IMessenger::Pointer messenger);
|
||||
IService::Pointer createSensorService(aasdk::messenger::IMessenger::Pointer messenger);
|
||||
IService::Pointer createVendorExtensionService(aasdk::messenger::IMessenger::Pointer messenger);
|
||||
IService::Pointer createWifiProjectionService(aasdk::messenger::IMessenger::Pointer messenger);
|
||||
|
||||
boost::asio::io_service &ioService_;
|
||||
configuration::IConfiguration::Pointer configuration_;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aasdk/Channel/VendorExtension/VendorExtensionService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <aasdk/Messenger/IMessenger.hpp>
|
||||
|
||||
|
||||
namespace f1x::openauto::autoapp::service::vendorextension {
|
||||
|
||||
class VendorExtensionService :
|
||||
public aasdk::channel::vendorextension::IVendorExtensionServiceEventHandler,
|
||||
public IService,
|
||||
public std::enable_shared_from_this<VendorExtensionService> {
|
||||
public:
|
||||
VendorExtensionService(boost::asio::io_service &ioService, aasdk::messenger::IMessenger::Pointer messenger);
|
||||
|
||||
void start() override;
|
||||
|
||||
void stop() override;
|
||||
|
||||
void pause() override;
|
||||
|
||||
void resume() override;
|
||||
|
||||
void fillFeatures(aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) override;
|
||||
|
||||
void onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) override;
|
||||
|
||||
void onChannelError(const aasdk::error::Error &e) override;
|
||||
|
||||
|
||||
private:
|
||||
using std::enable_shared_from_this<VendorExtensionService>::shared_from_this;
|
||||
boost::asio::deadline_timer timer_;
|
||||
boost::asio::io_service::strand strand_;
|
||||
aasdk::channel::vendorextension::VendorExtensionService::Pointer channel_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,70 +0,0 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <aasdk/Channel/AV/VideoServiceChannel.hpp>
|
||||
#include <aasdk/Channel/AV/IVideoServiceChannelEventHandler.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/IVideoOutput.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace service
|
||||
{
|
||||
|
||||
class VideoService: public aasdk::channel::av::IVideoServiceChannelEventHandler, public IService, public std::enable_shared_from_this<VideoService>
|
||||
{
|
||||
public:
|
||||
typedef std::shared_ptr<VideoService> Pointer;
|
||||
|
||||
VideoService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IVideoOutput::Pointer videoOutput);
|
||||
|
||||
void start() override;
|
||||
void stop() override;
|
||||
void pause() override;
|
||||
void resume() override;
|
||||
void fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response) override;
|
||||
void onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request) override;
|
||||
void onAVChannelSetupRequest(const aasdk::proto::messages::AVChannelSetupRequest& request) override;
|
||||
void onAVChannelStartIndication(const aasdk::proto::messages::AVChannelStartIndication& indication) override;
|
||||
void onAVChannelStopIndication(const aasdk::proto::messages::AVChannelStopIndication& indication) override;
|
||||
void onAVMediaWithTimestampIndication(aasdk::messenger::Timestamp::ValueType timestamp, const aasdk::common::DataConstBuffer& buffer) override;
|
||||
void onAVMediaIndication(const aasdk::common::DataConstBuffer& buffer) override;
|
||||
void onVideoFocusRequest(const aasdk::proto::messages::VideoFocusRequest& request) override;
|
||||
void onChannelError(const aasdk::error::Error& e) override;
|
||||
|
||||
private:
|
||||
using std::enable_shared_from_this<VideoService>::shared_from_this;
|
||||
void sendVideoFocusIndication();
|
||||
|
||||
boost::asio::io_service::strand strand_;
|
||||
aasdk::channel::av::VideoServiceChannel::Pointer channel_;
|
||||
projection::IVideoOutput::Pointer videoOutput_;
|
||||
int32_t session_;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -18,46 +18,48 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
||||
#include <aasdk/Channel/WifiProjection/WifiProjectionService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <aasdk/Messenger/IMessenger.hpp>
|
||||
#include <aasdk/Channel/WIFI/WIFIServiceChannel.hpp>
|
||||
#include <aasdk/Channel/WIFI/IWIFIServiceChannelEventHandler.hpp>
|
||||
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace service
|
||||
{
|
||||
namespace f1x::openauto::autoapp::service::wifiprojection {
|
||||
|
||||
class WifiService: public aasdk::channel::wifi::IWIFIServiceChannelEventHandler, public IService, public std::enable_shared_from_this<WifiService>
|
||||
{
|
||||
public:
|
||||
typedef std::shared_ptr<WifiService> Pointer;
|
||||
|
||||
WifiService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, configuration::IConfiguration::Pointer configuration);
|
||||
class WifiProjectionService :
|
||||
public aasdk::channel::wifiprojection::IWifiProjectionServiceEventHandler,
|
||||
public IService,
|
||||
public std::enable_shared_from_this<WifiProjectionService> {
|
||||
public:
|
||||
WifiProjectionService(boost::asio::io_service &ioService, aasdk::messenger::IMessenger::Pointer messenger, configuration::IConfiguration::Pointer configuration);
|
||||
|
||||
void start() override;
|
||||
|
||||
void stop() override;
|
||||
|
||||
void pause() override;
|
||||
|
||||
void resume() override;
|
||||
void fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response) override;
|
||||
void onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request) override;
|
||||
void onChannelError(const aasdk::error::Error& e) override;
|
||||
void onWifiSecurityRequest() override;
|
||||
|
||||
private:
|
||||
using std::enable_shared_from_this<WifiService>::shared_from_this;
|
||||
void fillFeatures(aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) override;
|
||||
|
||||
void onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) override;
|
||||
|
||||
void onChannelError(const aasdk::error::Error &e) override;
|
||||
|
||||
void
|
||||
onWifiCredentialsRequest(
|
||||
const aap_protobuf::service::wifiprojection::message::WifiCredentialsRequest &request) override;
|
||||
|
||||
private:
|
||||
using std::enable_shared_from_this<WifiProjectionService>::shared_from_this;
|
||||
configuration::IConfiguration::Pointer configuration_;
|
||||
boost::asio::deadline_timer timer_;
|
||||
boost::asio::io_service::strand strand_;
|
||||
aasdk::channel::wifi::WIFIServiceChannel::Pointer channel_;
|
||||
};
|
||||
aasdk::channel::wifiprojection::WifiProjectionService::Pointer channel_;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -18,12 +18,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <QWidget>
|
||||
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
||||
#include <QFileDialog>
|
||||
#include <QComboBox>
|
||||
#include <QKeyEvent>
|
||||
#include <sys/sysinfo.h>
|
||||
#ifdef MAC_OS
|
||||
#else
|
||||
#include <sys/sysinfo.h>
|
||||
#endif
|
||||
|
||||
class QCheckBox;
|
||||
class QTimer;
|
||||
@ -33,13 +36,7 @@ namespace Ui
|
||||
class SettingsWindow;
|
||||
}
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace ui
|
||||
namespace f1x::openauto::autoapp::ui
|
||||
{
|
||||
|
||||
class SettingsWindow : public QWidget
|
||||
@ -51,7 +48,7 @@ public:
|
||||
void loadSystemValues();
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
void keyPressEvent(QKeyEvent *event) override;
|
||||
|
||||
private slots:
|
||||
void unpairAll();
|
||||
@ -96,18 +93,29 @@ public slots:
|
||||
void show_tab9();
|
||||
|
||||
private:
|
||||
void showEvent(QShowEvent* event);
|
||||
void showEvent(QShowEvent* event) override;
|
||||
void load();
|
||||
void loadButtonCheckBoxes();
|
||||
void saveButtonCheckBoxes();
|
||||
void saveButtonCheckBox(const QCheckBox* checkBox, configuration::IConfiguration::ButtonCodes& buttonCodes, aasdk::proto::enums::ButtonCode::Enum buttonCode);
|
||||
void saveButtonCheckBox(const QCheckBox* checkBox, configuration::IConfiguration::ButtonCodes& buttonCodes, aap_protobuf::service::media::sink::message::KeyCode buttonCode);
|
||||
void setButtonCheckBoxes(bool value);
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
void populateBluetoothComboBoxLinux(QComboBox *comboBoxBluetooth);
|
||||
#endif
|
||||
#ifdef Q_OS_WIN
|
||||
void populateBluetoothComboBoxWindows(QComboBox *comboBoxBluetooth);
|
||||
#endif
|
||||
#ifdef Q_OS_MAC
|
||||
void populateBluetoothComboBoxMac(QComboBox *comboBoxBluetooth);
|
||||
#endif
|
||||
void populateBluetoothComboBox(QComboBox *comboBoxBluetooth);
|
||||
Ui::SettingsWindow* ui_;
|
||||
configuration::IConfiguration::Pointer configuration_;
|
||||
|
||||
void getMacMemoryInfo(QString &freeMemory);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -24,29 +24,34 @@
|
||||
#include <f1x/openauto/btservice/IAndroidBluetoothServer.hpp>
|
||||
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
||||
#include <aasdk/Messenger/Message.hpp>
|
||||
#include <aap_protobuf/aaw/MessageId.pb.h>
|
||||
#include <aap_protobuf/aaw/Status.pb.h>
|
||||
#include <aap_protobuf/aaw/WifiConnectionStatus.pb.h>
|
||||
#include <aap_protobuf/aaw/WifiInfoResponse.pb.h>
|
||||
#include <aap_protobuf/aaw/WifiVersionRequest.pb.h>
|
||||
#include <aap_protobuf/aaw/WifiVersionResponse.pb.h>
|
||||
#include <aap_protobuf/aaw/WifiStartResponse.pb.h>
|
||||
#include <aap_protobuf/aaw/WifiStartRequest.pb.h>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace btservice
|
||||
{
|
||||
|
||||
class AndroidBluetoothServer: public QObject, public IAndroidBluetoothServer
|
||||
{
|
||||
Q_OBJECT
|
||||
namespace f1x::openauto::btservice {
|
||||
|
||||
public:
|
||||
class AndroidBluetoothServer : public QObject, public IAndroidBluetoothServer {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AndroidBluetoothServer(autoapp::configuration::IConfiguration::Pointer configuration);
|
||||
|
||||
uint16_t start(const QBluetoothAddress& address) override;
|
||||
uint16_t start(const QBluetoothAddress &address) override;
|
||||
|
||||
private slots:
|
||||
|
||||
private slots:
|
||||
void onClientConnected();
|
||||
void onError(QBluetoothServer::Error error);
|
||||
|
||||
private:
|
||||
private:
|
||||
std::unique_ptr<QBluetoothServer> rfcommServer_;
|
||||
QBluetoothSocket* socket = nullptr;
|
||||
QBluetoothSocket *socket = nullptr;
|
||||
autoapp::configuration::IConfiguration::Pointer configuration_;
|
||||
|
||||
void readSocket();
|
||||
@ -55,15 +60,20 @@ private:
|
||||
|
||||
void handleWifiInfoRequest(QByteArray &buffer, uint16_t length);
|
||||
|
||||
void handleWifiVersionResponse(QByteArray &buffer, uint16_t length);
|
||||
|
||||
void handleWifiConnectionStatus(QByteArray &buffer, uint16_t length);
|
||||
|
||||
void handleWifiStartResponse(QByteArray &buffer, uint16_t length);
|
||||
|
||||
void sendMessage(const google::protobuf::Message &message, uint16_t type);
|
||||
|
||||
void handleWifiSecurityRequest(QByteArray &buffer, uint16_t length);
|
||||
|
||||
void handleWifiInfoRequestResponse(QByteArray &buffer, uint16_t length);
|
||||
|
||||
const ::std::string getIP4_(const QString intf);
|
||||
};
|
||||
|
||||
void DecodeProtoMessage(const std::string &proto_data);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -21,19 +21,15 @@
|
||||
#include <QBluetoothServiceInfo>
|
||||
#include <f1x/openauto/btservice/IAndroidBluetoothService.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace btservice
|
||||
namespace f1x::openauto::btservice
|
||||
{
|
||||
|
||||
class AndroidBluetoothService: public IAndroidBluetoothService
|
||||
{
|
||||
public:
|
||||
AndroidBluetoothService(uint16_t portNumber);
|
||||
AndroidBluetoothService();
|
||||
|
||||
bool registerService(const QBluetoothAddress& bluetoothAddress) override;
|
||||
bool registerService(int16_t portNumber, const QBluetoothAddress& bluetoothAddress) override;
|
||||
bool unregisterService() override;
|
||||
|
||||
private:
|
||||
@ -41,5 +37,5 @@ private:
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
45
include/f1x/openauto/btservice/BluetoothHandler.hpp
Normal file
45
include/f1x/openauto/btservice/BluetoothHandler.hpp
Normal file
@ -0,0 +1,45 @@
|
||||
//
|
||||
// Created by Simon Dean on 26/11/2024.
|
||||
//
|
||||
|
||||
#ifndef OPENAUTO_BLUETOOTHHANDLER_HPP
|
||||
#define OPENAUTO_BLUETOOTHHANDLER_HPP
|
||||
|
||||
#include <f1x/openauto/btservice/IBluetoothHandler.hpp>
|
||||
#include <f1x/openauto/btservice/IAndroidBluetoothServer.hpp>
|
||||
#include <f1x/openauto/btservice/IAndroidBluetoothService.hpp>
|
||||
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
||||
#include <QObject>
|
||||
|
||||
namespace f1x::openauto::btservice {
|
||||
|
||||
class BluetoothHandler : public QObject, public IBluetoothHandler {
|
||||
Q_OBJECT
|
||||
public:
|
||||
BluetoothHandler(btservice::IAndroidBluetoothService::Pointer androidBluetoothService,
|
||||
autoapp::configuration::IConfiguration::Pointer configuration);
|
||||
|
||||
void shutdownService() override;
|
||||
|
||||
private slots:
|
||||
void onPairingDisplayPinCode(const QBluetoothAddress &address, QString pin);
|
||||
|
||||
void onPairingDisplayConfirmation(const QBluetoothAddress &address, QString pin);
|
||||
|
||||
void onPairingFinished(const QBluetoothAddress &address, QBluetoothLocalDevice::Pairing pairing);
|
||||
|
||||
void onError(QBluetoothLocalDevice::Error error);
|
||||
|
||||
void onHostModeStateChanged(QBluetoothLocalDevice::HostMode state);
|
||||
|
||||
|
||||
private:
|
||||
std::unique_ptr<QBluetoothLocalDevice> localDevice_;
|
||||
autoapp::configuration::IConfiguration::Pointer configuration_;
|
||||
btservice::IAndroidBluetoothService::Pointer androidBluetoothService_;
|
||||
btservice::IAndroidBluetoothServer::Pointer androidBluetoothServer_;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif //OPENAUTO_BLUETOOTHHANDLER_HPP
|
@ -18,23 +18,20 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <QBluetoothAddress>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace btservice
|
||||
{
|
||||
namespace f1x::openauto::btservice {
|
||||
|
||||
class IAndroidBluetoothServer {
|
||||
public:
|
||||
typedef std::shared_ptr<IAndroidBluetoothServer> Pointer;
|
||||
|
||||
class IAndroidBluetoothServer
|
||||
{
|
||||
public:
|
||||
virtual ~IAndroidBluetoothServer() = default;
|
||||
|
||||
virtual uint16_t start(const QBluetoothAddress& address) = 0;
|
||||
};
|
||||
virtual uint16_t start(const QBluetoothAddress &address) = 0;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -17,25 +17,23 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <QBluetoothAddress>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace btservice
|
||||
namespace f1x::openauto::btservice
|
||||
{
|
||||
|
||||
class IAndroidBluetoothService
|
||||
{
|
||||
public:
|
||||
virtual ~IAndroidBluetoothService() = default;
|
||||
typedef std::shared_ptr<IAndroidBluetoothService> Pointer;
|
||||
|
||||
virtual bool registerService(const QBluetoothAddress& bluetoothAddress) = 0;
|
||||
virtual bool unregisterService() = 0;
|
||||
virtual ~IAndroidBluetoothService() = default;
|
||||
|
||||
virtual bool registerService(int16_t portNumber, const QBluetoothAddress& bluetoothAddress) = 0;
|
||||
virtual bool unregisterService() = 0;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
26
include/f1x/openauto/btservice/IBluetoothHandler.hpp
Normal file
26
include/f1x/openauto/btservice/IBluetoothHandler.hpp
Normal file
@ -0,0 +1,26 @@
|
||||
//
|
||||
// Created by Simon Dean on 26/11/2024.
|
||||
//
|
||||
|
||||
#ifndef OPENAUTO_IBLUETOOTHHANDLER_HPP
|
||||
#define OPENAUTO_IBLUETOOTHHANDLER_HPP
|
||||
|
||||
#include <memory>
|
||||
#include <QBluetoothAddress>
|
||||
#include <QBluetoothLocalDevice>
|
||||
|
||||
namespace f1x::openauto::btservice {
|
||||
|
||||
class IBluetoothHandler
|
||||
{
|
||||
public:
|
||||
virtual ~IBluetoothHandler() = default;
|
||||
|
||||
virtual void shutdownService() = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif //OPENAUTO_IBLUETOOTHHANDLER_HPP
|
@ -22,171 +22,145 @@
|
||||
#include <f1x/openauto/autoapp/App.hpp>
|
||||
#include <f1x/openauto/Common/Log.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace f1x::openauto::autoapp {
|
||||
|
||||
App::App(boost::asio::io_service& ioService, aasdk::usb::USBWrapper& usbWrapper, aasdk::tcp::ITCPWrapper& tcpWrapper, service::IAndroidAutoEntityFactory& androidAutoEntityFactory,
|
||||
aasdk::usb::IUSBHub::Pointer usbHub, aasdk::usb::IConnectedAccessoriesEnumerator::Pointer connectedAccessoriesEnumerator)
|
||||
: ioService_(ioService)
|
||||
, usbWrapper_(usbWrapper)
|
||||
, tcpWrapper_(tcpWrapper)
|
||||
, strand_(ioService_)
|
||||
, androidAutoEntityFactory_(androidAutoEntityFactory)
|
||||
, usbHub_(std::move(usbHub))
|
||||
, connectedAccessoriesEnumerator_(std::move(connectedAccessoriesEnumerator))
|
||||
, acceptor_(ioService, boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), 5000 ))
|
||||
, isStopped_(false)
|
||||
{
|
||||
App::App(boost::asio::io_service &ioService, aasdk::usb::USBWrapper &usbWrapper, aasdk::tcp::ITCPWrapper &tcpWrapper,
|
||||
service::IAndroidAutoEntityFactory &androidAutoEntityFactory,
|
||||
aasdk::usb::IUSBHub::Pointer usbHub,
|
||||
aasdk::usb::IConnectedAccessoriesEnumerator::Pointer connectedAccessoriesEnumerator)
|
||||
: ioService_(ioService), usbWrapper_(usbWrapper), tcpWrapper_(tcpWrapper), strand_(ioService_),
|
||||
androidAutoEntityFactory_(androidAutoEntityFactory), usbHub_(std::move(usbHub)),
|
||||
connectedAccessoriesEnumerator_(std::move(connectedAccessoriesEnumerator)),
|
||||
acceptor_(ioService, boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), 5000)), isStopped_(false) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void App::waitForUSBDevice()
|
||||
{
|
||||
void App::waitForUSBDevice() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
try
|
||||
{
|
||||
this->waitForDevice();
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
OPENAUTO_LOG(error) << "[App] waitForUSBDevice() -exception caused by this->waitForDevice();";
|
||||
}
|
||||
try
|
||||
{
|
||||
this->enumerateDevices();
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
OPENAUTO_LOG(error) << "[App] waitForUSBDevice() exception caused by this->enumerateDevices()";
|
||||
}
|
||||
try {
|
||||
this->waitForDevice();
|
||||
}
|
||||
catch (...) {
|
||||
OPENAUTO_LOG(error) << "[App] waitForUSBDevice() -exception caused by this->waitForDevice();";
|
||||
}
|
||||
try {
|
||||
this->enumerateDevices();
|
||||
}
|
||||
catch (...) {
|
||||
OPENAUTO_LOG(error) << "[App] waitForUSBDevice() exception caused by this->enumerateDevices()";
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void App::start(aasdk::tcp::ITCPEndpoint::SocketPointer socket)
|
||||
{
|
||||
void App::start(aasdk::tcp::ITCPEndpoint::SocketPointer socket) {
|
||||
strand_.dispatch([this, self = this->shared_from_this(), socket = std::move(socket)]() mutable {
|
||||
OPENAUTO_LOG(info) << "Start from socket";
|
||||
if(androidAutoEntity_ != nullptr)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "Start from socket";
|
||||
if (androidAutoEntity_ != nullptr) {
|
||||
// tcpWrapper_.close(*socket);
|
||||
// OPENAUTO_LOG(warning) << "[App] android auto entity is still running.";
|
||||
// return;
|
||||
try {
|
||||
androidAutoEntity_->stop();
|
||||
} catch (...) {
|
||||
OPENAUTO_LOG(error) << "[App] onAndroidAutoQuit: exception caused by androidAutoEntity_->stop();";
|
||||
}
|
||||
try {
|
||||
androidAutoEntity_.reset();
|
||||
} catch (...) {
|
||||
OPENAUTO_LOG(error) << "[App] onAndroidAutoQuit: exception caused by androidAutoEntity_.reset();";
|
||||
}
|
||||
try {
|
||||
androidAutoEntity_->stop();
|
||||
} catch (...) {
|
||||
OPENAUTO_LOG(error) << "[App] onAndroidAutoQuit: exception caused by androidAutoEntity_->stop();";
|
||||
}
|
||||
try {
|
||||
androidAutoEntity_.reset();
|
||||
} catch (...) {
|
||||
OPENAUTO_LOG(error) << "[App] onAndroidAutoQuit: exception caused by androidAutoEntity_.reset();";
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
// usbHub_->cancel();
|
||||
// connectedAccessoriesEnumerator_->cancel();
|
||||
|
||||
auto tcpEndpoint(std::make_shared<aasdk::tcp::TCPEndpoint>(tcpWrapper_, std::move(socket)));
|
||||
androidAutoEntity_ = androidAutoEntityFactory_.create(std::move(tcpEndpoint));
|
||||
androidAutoEntity_->start(*this);
|
||||
}
|
||||
catch(const aasdk::error::Error& error)
|
||||
{
|
||||
OPENAUTO_LOG(error) << "[App] TCP AndroidAutoEntity create error: " << error.what();
|
||||
auto tcpEndpoint(std::make_shared<aasdk::tcp::TCPEndpoint>(tcpWrapper_, std::move(socket)));
|
||||
androidAutoEntity_ = androidAutoEntityFactory_.create(std::move(tcpEndpoint));
|
||||
androidAutoEntity_->start(*this);
|
||||
}
|
||||
catch (const aasdk::error::Error &error) {
|
||||
OPENAUTO_LOG(error) << "[App] TCP AndroidAutoEntity create error: " << error.what();
|
||||
|
||||
//androidAutoEntity_.reset();
|
||||
this->waitForDevice();
|
||||
}
|
||||
//androidAutoEntity_.reset();
|
||||
this->waitForDevice();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void App::stop()
|
||||
{
|
||||
void App::stop() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
isStopped_ = true;
|
||||
try {
|
||||
connectedAccessoriesEnumerator_->cancel();
|
||||
} catch (...) {
|
||||
OPENAUTO_LOG(error) << "[App] stop: exception caused by connectedAccessoriesEnumerator_->cancel()";
|
||||
}
|
||||
try {
|
||||
usbHub_->cancel();
|
||||
} catch (...) {
|
||||
OPENAUTO_LOG(error) << "[App] stop: exception caused by usbHub_->cancel();";
|
||||
}
|
||||
isStopped_ = true;
|
||||
try {
|
||||
connectedAccessoriesEnumerator_->cancel();
|
||||
} catch (...) {
|
||||
OPENAUTO_LOG(error) << "[App] stop: exception caused by connectedAccessoriesEnumerator_->cancel()";
|
||||
}
|
||||
try {
|
||||
usbHub_->cancel();
|
||||
} catch (...) {
|
||||
OPENAUTO_LOG(error) << "[App] stop: exception caused by usbHub_->cancel();";
|
||||
}
|
||||
|
||||
if(androidAutoEntity_ != nullptr)
|
||||
{
|
||||
try {
|
||||
androidAutoEntity_->stop();
|
||||
} catch (...) {
|
||||
OPENAUTO_LOG(error) << "[App] stop: exception caused by androidAutoEntity_->stop();";
|
||||
}
|
||||
try {
|
||||
androidAutoEntity_.reset();
|
||||
} catch (...) {
|
||||
OPENAUTO_LOG(error) << "[App] stop: exception caused by androidAutoEntity_.reset();";
|
||||
}
|
||||
if (androidAutoEntity_ != nullptr) {
|
||||
try {
|
||||
androidAutoEntity_->stop();
|
||||
} catch (...) {
|
||||
OPENAUTO_LOG(error) << "[App] stop: exception caused by androidAutoEntity_->stop();";
|
||||
}
|
||||
try {
|
||||
androidAutoEntity_.reset();
|
||||
} catch (...) {
|
||||
OPENAUTO_LOG(error) << "[App] stop: exception caused by androidAutoEntity_.reset();";
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void App::aoapDeviceHandler(aasdk::usb::DeviceHandle deviceHandle)
|
||||
{
|
||||
void App::aoapDeviceHandler(aasdk::usb::DeviceHandle deviceHandle) {
|
||||
OPENAUTO_LOG(info) << "[App] Device connected.";
|
||||
|
||||
if(androidAutoEntity_ != nullptr)
|
||||
{
|
||||
OPENAUTO_LOG(warning) << "[App] android auto entity is still running.";
|
||||
return;
|
||||
if (androidAutoEntity_ != nullptr) {
|
||||
OPENAUTO_LOG(warning) << "[App] android auto entity is still running.";
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// ignore autostart if exit to csng was used
|
||||
if (!disableAutostartEntity) {
|
||||
OPENAUTO_LOG(info) << "[App] Start Android Auto allowed - let's go.";
|
||||
connectedAccessoriesEnumerator_->cancel();
|
||||
try {
|
||||
// ignore autostart if exit to csng was used
|
||||
if (!disableAutostartEntity) {
|
||||
OPENAUTO_LOG(info) << "[App] Start Android Auto allowed - let's go.";
|
||||
connectedAccessoriesEnumerator_->cancel();
|
||||
|
||||
auto aoapDevice(aasdk::usb::AOAPDevice::create(usbWrapper_, ioService_, deviceHandle));
|
||||
androidAutoEntity_ = androidAutoEntityFactory_.create(std::move(aoapDevice));
|
||||
androidAutoEntity_->start(*this);
|
||||
} else {
|
||||
OPENAUTO_LOG(info) << "[App] Start Android Auto not allowed - skip.";
|
||||
}
|
||||
auto aoapDevice(aasdk::usb::AOAPDevice::create(usbWrapper_, ioService_, deviceHandle));
|
||||
androidAutoEntity_ = androidAutoEntityFactory_.create(std::move(aoapDevice));
|
||||
androidAutoEntity_->start(*this);
|
||||
} else {
|
||||
OPENAUTO_LOG(info) << "[App] Start Android Auto not allowed - skip.";
|
||||
}
|
||||
}
|
||||
catch(const aasdk::error::Error& error)
|
||||
{
|
||||
OPENAUTO_LOG(error) << "[App] USB AndroidAutoEntity create error: " << error.what();
|
||||
catch (const aasdk::error::Error &error) {
|
||||
OPENAUTO_LOG(error) << "[App] USB AndroidAutoEntity create error: " << error.what();
|
||||
|
||||
androidAutoEntity_.reset();
|
||||
this->waitForDevice();
|
||||
androidAutoEntity_.reset();
|
||||
this->waitForDevice();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void App::enumerateDevices()
|
||||
{
|
||||
void App::enumerateDevices() {
|
||||
auto promise = aasdk::usb::IConnectedAccessoriesEnumerator::Promise::defer(strand_);
|
||||
promise->then([this, self = this->shared_from_this()](auto result) {
|
||||
OPENAUTO_LOG(info) << "[App] Devices enumeration result: " << result;
|
||||
},
|
||||
[this, self = this->shared_from_this()](auto e) {
|
||||
OPENAUTO_LOG(error) << "[App] Devices enumeration failed: " << e.what();
|
||||
});
|
||||
OPENAUTO_LOG(info) << "[App] Devices enumeration result: " << result;
|
||||
},
|
||||
[this, self = this->shared_from_this()](auto e) {
|
||||
OPENAUTO_LOG(error) << "[App] Devices enumeration failed: " << e.what();
|
||||
});
|
||||
|
||||
connectedAccessoriesEnumerator_->enumerate(std::move(promise));
|
||||
}
|
||||
}
|
||||
|
||||
void App::waitForDevice()
|
||||
{
|
||||
void App::waitForDevice() {
|
||||
OPENAUTO_LOG(info) << "[App] Waiting for device...";
|
||||
|
||||
auto promise = aasdk::usb::IUSBHub::Promise::defer(strand_);
|
||||
@ -194,81 +168,76 @@ void App::waitForDevice()
|
||||
std::bind(&App::onUSBHubError, this->shared_from_this(), std::placeholders::_1));
|
||||
usbHub_->start(std::move(promise));
|
||||
startServerSocket();
|
||||
}
|
||||
}
|
||||
|
||||
void App::startServerSocket() {
|
||||
void App::startServerSocket() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "Listening for WIFI clients on port 5000";
|
||||
auto socket = std::make_shared<boost::asio::ip::tcp::socket>(ioService_);
|
||||
acceptor_.async_accept(
|
||||
*socket,
|
||||
std::bind(&App::handleNewClient, this, socket, std::placeholders::_1)
|
||||
);
|
||||
OPENAUTO_LOG(info) << "startServerSocket() - Listening for WIFI Clients on Port 5000";
|
||||
auto socket = std::make_shared<boost::asio::ip::tcp::socket>(ioService_);
|
||||
acceptor_.async_accept(
|
||||
*socket,
|
||||
std::bind(&App::handleNewClient, this, socket, std::placeholders::_1)
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void App::handleNewClient(std::shared_ptr<boost::asio::ip::tcp::socket> socket, const boost::system::error_code &err) {
|
||||
OPENAUTO_LOG(info) << "WIFI Client connected";
|
||||
void
|
||||
App::handleNewClient(std::shared_ptr<boost::asio::ip::tcp::socket> socket, const boost::system::error_code &err) {
|
||||
OPENAUTO_LOG(info) << "handleNewClient() - Handle WIFI Client Connection";
|
||||
if (!err) {
|
||||
start(std::move(socket));
|
||||
start(std::move(socket));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void App::pause()
|
||||
{
|
||||
void App::pause() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[App] pause...";
|
||||
androidAutoEntity_->pause();
|
||||
OPENAUTO_LOG(info) << "[App] pause...";
|
||||
androidAutoEntity_->pause();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void App::resume()
|
||||
{
|
||||
void App::resume() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
if(androidAutoEntity_ != nullptr)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[App] resume...";
|
||||
androidAutoEntity_->resume();
|
||||
} else {
|
||||
OPENAUTO_LOG(info) << "[App] Ignore resume -> no androidAutoEntity_ ...";
|
||||
}
|
||||
if (androidAutoEntity_ != nullptr) {
|
||||
OPENAUTO_LOG(info) << "[App] resume...";
|
||||
androidAutoEntity_->resume();
|
||||
} else {
|
||||
OPENAUTO_LOG(info) << "[App] Ignore resume -> no androidAutoEntity_ ...";
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void App::onAndroidAutoQuit()
|
||||
{
|
||||
void App::onAndroidAutoQuit() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[App] onAndroidAutoQuit.";
|
||||
OPENAUTO_LOG(info) << "[App] onAndroidAutoQuit()";
|
||||
|
||||
//acceptor_.close();
|
||||
//acceptor_.close();
|
||||
|
||||
if (androidAutoEntity_ != nullptr) {
|
||||
try {
|
||||
androidAutoEntity_->stop();
|
||||
} catch (...) {
|
||||
OPENAUTO_LOG(error) << "[App] onAndroidAutoQuit: exception caused by androidAutoEntity_->stop();";
|
||||
}
|
||||
try {
|
||||
androidAutoEntity_.reset();
|
||||
} catch (...) {
|
||||
OPENAUTO_LOG(error) << "[App] onAndroidAutoQuit: exception caused by androidAutoEntity_.reset();";
|
||||
}
|
||||
if (androidAutoEntity_ != nullptr) {
|
||||
try {
|
||||
androidAutoEntity_->stop();
|
||||
} catch (...) {
|
||||
OPENAUTO_LOG(error) << "[App] onAndroidAutoQuit: exception caused by androidAutoEntity_->stop();";
|
||||
}
|
||||
|
||||
if(!isStopped_)
|
||||
{
|
||||
try {
|
||||
this->waitForDevice();
|
||||
} catch (...) {
|
||||
OPENAUTO_LOG(error) << "[App] onAndroidAutoQuit: exception caused by this->waitForDevice();";
|
||||
}
|
||||
try {
|
||||
androidAutoEntity_.reset();
|
||||
} catch (...) {
|
||||
OPENAUTO_LOG(error) << "[App] onAndroidAutoQuit: exception caused by androidAutoEntity_.reset();";
|
||||
}
|
||||
}
|
||||
|
||||
if (!isStopped_) {
|
||||
try {
|
||||
this->waitForDevice();
|
||||
} catch (...) {
|
||||
OPENAUTO_LOG(error) << "[App] onAndroidAutoQuit: exception caused by this->waitForDevice();";
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void App::onUSBHubError(const aasdk::error::Error& error)
|
||||
{
|
||||
OPENAUTO_LOG(error) << "[App] usb hub error: " << error.what();
|
||||
void App::onUSBHubError(const aasdk::error::Error &error) {
|
||||
OPENAUTO_LOG(error) << "[App] onUSBHubError(): " << error.what();
|
||||
|
||||
// if(error != aasdk::error::ErrorCode::OPERATION_ABORTED &&
|
||||
// error != aasdk::error::ErrorCode::OPERATION_IN_PROGRESS)
|
||||
@ -279,8 +248,8 @@ void App::onUSBHubError(const aasdk::error::Error& error)
|
||||
// OPENAUTO_LOG(error) << "[App] onUSBHubError: exception caused by this->waitForDevice();";
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -20,13 +20,10 @@
|
||||
#include <f1x/openauto/Common/Log.hpp>
|
||||
#include <QTouchDevice>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace configuration
|
||||
|
||||
|
||||
|
||||
namespace f1x::openauto::autoapp::configuration
|
||||
{
|
||||
|
||||
const std::string Configuration::cConfigFileName = "openauto.ini";
|
||||
@ -60,12 +57,15 @@ const std::string Configuration::cVideoOMXLayerIndexKey = "Video.OMXLayerIndex";
|
||||
const std::string Configuration::cVideoMarginWidth = "Video.MarginWidth";
|
||||
const std::string Configuration::cVideoMarginHeight = "Video.MarginHeight";
|
||||
|
||||
const std::string Configuration::cAudioMusicAudioChannelEnabled = "Audio.MusicAudioChannelEnabled";
|
||||
const std::string Configuration::cAudioSpeechAudioChannelEnabled = "Audio.SpeechAudioChannelEnabled";
|
||||
const std::string Configuration::cAudioChannelMediaEnabled = "AudioChannel.MediaEnabled";
|
||||
const std::string Configuration::cAudioChannelGuidanceEnabled = "AudioChannel.GuidanceEnabled";
|
||||
const std::string Configuration::cAudioChannelSystemEnabled = "AudioChannel.SystemEnabled";
|
||||
const std::string Configuration::cAudioChannelTelephonyEnabled = "AudioChannel.TelephonyEnabled";
|
||||
|
||||
const std::string Configuration::cAudioOutputBackendType = "Audio.OutputBackendType";
|
||||
|
||||
const std::string Configuration::cBluetoothAdapterTypeKey = "Bluetooth.AdapterType";
|
||||
const std::string Configuration::cBluetoothRemoteAdapterAddressKey = "Bluetooth.RemoteAdapterAddress";
|
||||
const std::string Configuration::cBluetoothAdapterAddressKey = "Bluetooth.AdapterAddress";
|
||||
const std::string Configuration::cBluetoothWirelessProjectionEnabledKey = "Bluetooth.WirelessProjectionEnabled";
|
||||
|
||||
const std::string Configuration::cInputEnableTouchscreenKey = "Input.EnableTouchscreen";
|
||||
@ -121,11 +121,11 @@ void Configuration::load()
|
||||
showAutoPlay_ = iniConfig.get<bool>(cGeneralShowAutoPlayKey, false);
|
||||
instantPlay_ = iniConfig.get<bool>(cGeneralInstantPlayKey, false);
|
||||
|
||||
videoFPS_ = static_cast<aasdk::proto::enums::VideoFPS::Enum>(iniConfig.get<uint32_t>(cVideoFPSKey,
|
||||
aasdk::proto::enums::VideoFPS::_30));
|
||||
videoFPS_ = static_cast<aap_protobuf::service::media::sink::message::VideoFrameRateType>(iniConfig.get<uint32_t>(cVideoFPSKey,
|
||||
aap_protobuf::service::media::sink::message::VideoFrameRateType::VIDEO_FPS_30));
|
||||
|
||||
videoResolution_ = static_cast<aasdk::proto::enums::VideoResolution::Enum>(iniConfig.get<uint32_t>(cVideoResolutionKey,
|
||||
aasdk::proto::enums::VideoResolution::_480p));
|
||||
videoResolution_ = static_cast<aap_protobuf::service::media::sink::message::VideoCodecResolutionType>(iniConfig.get<uint32_t>(cVideoResolutionKey,
|
||||
aap_protobuf::service::media::sink::message::VideoCodecResolutionType::VIDEO_800x480));
|
||||
screenDPI_ = iniConfig.get<size_t>(cVideoScreenDPIKey, 140);
|
||||
|
||||
omxLayerIndex_ = iniConfig.get<int32_t>(cVideoOMXLayerIndexKey, 1);
|
||||
@ -140,10 +140,14 @@ void Configuration::load()
|
||||
|
||||
wirelessProjectionEnabled_ = iniConfig.get<bool>(cBluetoothWirelessProjectionEnabledKey, true);
|
||||
|
||||
bluetoothRemoteAdapterAddress_ = iniConfig.get<std::string>(cBluetoothRemoteAdapterAddressKey, "");
|
||||
musicAudioChannelEnabled_ = iniConfig.get<bool>(cAudioMusicAudioChannelEnabled, true);
|
||||
speechAudiochannelEnabled_ = iniConfig.get<bool>(cAudioSpeechAudioChannelEnabled, true);
|
||||
audioOutputBackendType_ = static_cast<AudioOutputBackendType>(iniConfig.get<uint32_t>(cAudioOutputBackendType, static_cast<uint32_t>(AudioOutputBackendType::RTAUDIO)));
|
||||
bluetoothAdapterAddress_ = iniConfig.get<std::string>(cBluetoothAdapterAddressKey, "");
|
||||
|
||||
_audioChannelEnabledMedia = iniConfig.get<bool>(cAudioChannelMediaEnabled, true);
|
||||
_audioChannelEnabledGuidance = iniConfig.get<bool>(cAudioChannelGuidanceEnabled, true);
|
||||
_audioChannelEnabledSystem = iniConfig.get<bool>(cAudioChannelSystemEnabled, true);
|
||||
_audioChannelEnabledTelephony = iniConfig.get<bool>(cAudioChannelTelephonyEnabled, true);
|
||||
|
||||
audioOutputBackendType_ = static_cast<AudioOutputBackendType>(iniConfig.get<uint32_t>(cAudioOutputBackendType, static_cast<uint32_t>(AudioOutputBackendType::RTAUDIO)));
|
||||
}
|
||||
catch(const boost::property_tree::ini_parser_error& e)
|
||||
{
|
||||
@ -174,8 +178,8 @@ void Configuration::reset()
|
||||
mp3AutoPlay_ = false;
|
||||
showAutoPlay_ = false;
|
||||
instantPlay_ = false;
|
||||
videoFPS_ = aasdk::proto::enums::VideoFPS::_30;
|
||||
videoResolution_ = aasdk::proto::enums::VideoResolution::_480p;
|
||||
videoFPS_ = aap_protobuf::service::media::sink::message::VideoFrameRateType::VIDEO_FPS_30;
|
||||
videoResolution_ = aap_protobuf::service::media::sink::message::VideoCodecResolutionType::VIDEO_800x480;
|
||||
screenDPI_ = 140;
|
||||
omxLayerIndex_ = 1;
|
||||
videoMargins_ = QRect(0, 0, 0, 0);
|
||||
@ -183,9 +187,13 @@ void Configuration::reset()
|
||||
enablePlayerControl_ = false;
|
||||
buttonCodes_.clear();
|
||||
bluetoothAdapterType_ = BluetoothAdapterType::NONE;
|
||||
bluetoothRemoteAdapterAddress_ = "";
|
||||
musicAudioChannelEnabled_ = true;
|
||||
speechAudiochannelEnabled_ = true;
|
||||
bluetoothAdapterAddress_ = "";
|
||||
|
||||
_audioChannelEnabledMedia = true;
|
||||
_audioChannelEnabledGuidance = true;
|
||||
_audioChannelEnabledSystem = true;
|
||||
_audioChannelEnabledTelephony = true;
|
||||
|
||||
audioOutputBackendType_ = AudioOutputBackendType::QT;
|
||||
wirelessProjectionEnabled_ = true;
|
||||
}
|
||||
@ -225,12 +233,15 @@ void Configuration::save()
|
||||
this->writeButtonCodes(iniConfig);
|
||||
|
||||
iniConfig.put<uint32_t>(cBluetoothAdapterTypeKey, static_cast<uint32_t>(bluetoothAdapterType_));
|
||||
iniConfig.put<std::string>(cBluetoothRemoteAdapterAddressKey, bluetoothRemoteAdapterAddress_);
|
||||
iniConfig.put<std::string>(cBluetoothAdapterAddressKey, bluetoothAdapterAddress_);
|
||||
iniConfig.put<bool>(cBluetoothWirelessProjectionEnabledKey, wirelessProjectionEnabled_);
|
||||
|
||||
iniConfig.put<bool>(cAudioMusicAudioChannelEnabled, musicAudioChannelEnabled_);
|
||||
iniConfig.put<bool>(cAudioSpeechAudioChannelEnabled, speechAudiochannelEnabled_);
|
||||
iniConfig.put<uint32_t>(cAudioOutputBackendType, static_cast<uint32_t>(audioOutputBackendType_));
|
||||
iniConfig.put<bool>(cAudioChannelMediaEnabled, _audioChannelEnabledMedia);
|
||||
iniConfig.put<bool>(cAudioChannelGuidanceEnabled, _audioChannelEnabledGuidance);
|
||||
iniConfig.put<bool>(cAudioChannelSystemEnabled, _audioChannelEnabledSystem);
|
||||
iniConfig.put<bool>(cAudioChannelTelephonyEnabled, _audioChannelEnabledTelephony);
|
||||
|
||||
iniConfig.put<uint32_t>(cAudioOutputBackendType, static_cast<uint32_t>(audioOutputBackendType_));
|
||||
boost::property_tree::ini_parser::write_ini(cConfigFileName, iniConfig);
|
||||
}
|
||||
|
||||
@ -433,22 +444,22 @@ bool Configuration::instantPlay() const
|
||||
return instantPlay_;
|
||||
}
|
||||
|
||||
aasdk::proto::enums::VideoFPS::Enum Configuration::getVideoFPS() const
|
||||
aap_protobuf::service::media::sink::message::VideoFrameRateType Configuration::getVideoFPS() const
|
||||
{
|
||||
return videoFPS_;
|
||||
}
|
||||
|
||||
void Configuration::setVideoFPS(aasdk::proto::enums::VideoFPS::Enum value)
|
||||
void Configuration::setVideoFPS(aap_protobuf::service::media::sink::message::VideoFrameRateType value)
|
||||
{
|
||||
videoFPS_ = value;
|
||||
}
|
||||
|
||||
aasdk::proto::enums::VideoResolution::Enum Configuration::getVideoResolution() const
|
||||
aap_protobuf::service::media::sink::message::VideoCodecResolutionType Configuration::getVideoResolution() const
|
||||
{
|
||||
return videoResolution_;
|
||||
}
|
||||
|
||||
void Configuration::setVideoResolution(aasdk::proto::enums::VideoResolution::Enum value)
|
||||
void Configuration::setVideoResolution(aap_protobuf::service::media::sink::message::VideoCodecResolutionType value)
|
||||
{
|
||||
videoResolution_ = value;
|
||||
}
|
||||
@ -523,14 +534,14 @@ void Configuration::setBluetoothAdapterType(BluetoothAdapterType value)
|
||||
bluetoothAdapterType_ = value;
|
||||
}
|
||||
|
||||
std::string Configuration::getBluetoothRemoteAdapterAddress() const
|
||||
std::string Configuration::getBluetoothAdapterAddress() const
|
||||
{
|
||||
return bluetoothRemoteAdapterAddress_;
|
||||
return bluetoothAdapterAddress_;
|
||||
}
|
||||
|
||||
void Configuration::setBluetoothRemoteAdapterAddress(const std::string& value)
|
||||
void Configuration::setBluetoothAdapterAddress(const std::string& value)
|
||||
{
|
||||
bluetoothRemoteAdapterAddress_ = value;
|
||||
bluetoothAdapterAddress_ = value;
|
||||
}
|
||||
|
||||
bool Configuration::getWirelessProjectionEnabled() const {
|
||||
@ -543,24 +554,44 @@ void Configuration::setWirelessProjectionEnabled(bool value) {
|
||||
|
||||
bool Configuration::musicAudioChannelEnabled() const
|
||||
{
|
||||
return musicAudioChannelEnabled_;
|
||||
return _audioChannelEnabledMedia;
|
||||
}
|
||||
|
||||
void Configuration::setMusicAudioChannelEnabled(bool value)
|
||||
{
|
||||
musicAudioChannelEnabled_ = value;
|
||||
_audioChannelEnabledMedia = value;
|
||||
}
|
||||
|
||||
bool Configuration::speechAudioChannelEnabled() const
|
||||
bool Configuration::guidanceAudioChannelEnabled() const
|
||||
{
|
||||
return speechAudiochannelEnabled_;
|
||||
return _audioChannelEnabledGuidance;
|
||||
}
|
||||
|
||||
void Configuration::setSpeechAudioChannelEnabled(bool value)
|
||||
void Configuration::setGuidanceAudioChannelEnabled(bool value)
|
||||
{
|
||||
speechAudiochannelEnabled_ = value;
|
||||
_audioChannelEnabledGuidance = value;
|
||||
}
|
||||
|
||||
bool Configuration::systemAudioChannelEnabled() const
|
||||
{
|
||||
return _audioChannelEnabledSystem;
|
||||
}
|
||||
|
||||
void Configuration::setSystemAudioChannelEnabled(bool value)
|
||||
{
|
||||
_audioChannelEnabledSystem = value;
|
||||
}
|
||||
|
||||
bool Configuration::telephonyAudioChannelEnabled() const
|
||||
{
|
||||
return _audioChannelEnabledTelephony;
|
||||
}
|
||||
|
||||
void Configuration::setTelephonyAudioChannelEnabled(bool value)
|
||||
{
|
||||
_audioChannelEnabledTelephony = value;
|
||||
}
|
||||
|
||||
AudioOutputBackendType Configuration::getAudioOutputBackendType() const
|
||||
{
|
||||
return audioOutputBackendType_;
|
||||
@ -594,7 +625,7 @@ QString Configuration::getCSValue(QString searchString) const
|
||||
int equalPosition = line.find("=");
|
||||
QString value = line.substr(equalPosition + 1).c_str();
|
||||
value.replace("\"","");
|
||||
OPENAUTO_LOG(info) << "[Configuration] CS param found: " << searchString.toStdString() << " Value:" << value.toStdString();
|
||||
OPENAUTO_LOG(debug) << "[Configuration] CS param found: " << searchString.toStdString() << " Value:" << value.toStdString();
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@ -611,7 +642,7 @@ QString Configuration::getCSValue(QString searchString) const
|
||||
int equalPosition = line.find("=");
|
||||
QString value = line.substr(equalPosition + 1).c_str();
|
||||
value.replace("\"","");
|
||||
OPENAUTO_LOG(info) << "[Configuration] CS param found: " << searchString.toStdString() << " Value:" << value.toStdString();
|
||||
OPENAUTO_LOG(debug) << "[Configuration] CS param found: " << searchString.toStdString() << " Value:" << value.toStdString();
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@ -631,7 +662,7 @@ QString Configuration::getCSValue(QString searchString) const
|
||||
int equalPosition = line.find("=");
|
||||
QString value = line.substr(equalPosition + 1).c_str();
|
||||
value.replace("\"","");
|
||||
OPENAUTO_LOG(info) << "[Configuration] CS param found: " << searchString.toStdString() << " Value:" << value.toStdString();
|
||||
OPENAUTO_LOG(debug) << "[Configuration] CS param found: " << searchString.toStdString() << " Value:" << value.toStdString();
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@ -642,7 +673,7 @@ QString Configuration::getCSValue(QString searchString) const
|
||||
|
||||
QString Configuration::getParamFromFile(QString fileName, QString searchString) const
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[Configuration] Request param from file: " << fileName.toStdString() << " param: " << searchString.toStdString();
|
||||
OPENAUTO_LOG(debug) << "[Configuration] Request param from file: " << fileName.toStdString() << " param: " << searchString.toStdString();
|
||||
using namespace std;
|
||||
ifstream inFile;
|
||||
string line;
|
||||
@ -664,7 +695,7 @@ QString Configuration::getParamFromFile(QString fileName, QString searchString)
|
||||
int equalPosition = line.find("=");
|
||||
QString value = line.substr(equalPosition + 1).c_str();
|
||||
value.replace("\"","");
|
||||
OPENAUTO_LOG(info) << "[Configuration] Param from file: " << fileName.toStdString() << " found: " << searchString.toStdString() << " Value:" << value.toStdString();
|
||||
OPENAUTO_LOG(debug) << "[Configuration] Param from file: " << fileName.toStdString() << " found: " << searchString.toStdString() << " Value:" << value.toStdString();
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@ -696,26 +727,26 @@ QString Configuration::readFileContent(QString fileName) const
|
||||
|
||||
void Configuration::readButtonCodes(boost::property_tree::ptree& iniConfig)
|
||||
{
|
||||
this->insertButtonCode(iniConfig, cInputPlayButtonKey, aasdk::proto::enums::ButtonCode::PLAY);
|
||||
this->insertButtonCode(iniConfig, cInputPauseButtonKey, aasdk::proto::enums::ButtonCode::PAUSE);
|
||||
this->insertButtonCode(iniConfig, cInputTogglePlayButtonKey, aasdk::proto::enums::ButtonCode::TOGGLE_PLAY);
|
||||
this->insertButtonCode(iniConfig, cInputNextTrackButtonKey, aasdk::proto::enums::ButtonCode::NEXT);
|
||||
this->insertButtonCode(iniConfig, cInputPreviousTrackButtonKey, aasdk::proto::enums::ButtonCode::PREV);
|
||||
this->insertButtonCode(iniConfig, cInputHomeButtonKey, aasdk::proto::enums::ButtonCode::HOME);
|
||||
this->insertButtonCode(iniConfig, cInputPhoneButtonKey, aasdk::proto::enums::ButtonCode::PHONE);
|
||||
this->insertButtonCode(iniConfig, cInputCallEndButtonKey, aasdk::proto::enums::ButtonCode::CALL_END);
|
||||
this->insertButtonCode(iniConfig, cInputVoiceCommandButtonKey, aasdk::proto::enums::ButtonCode::MICROPHONE_1);
|
||||
this->insertButtonCode(iniConfig, cInputLeftButtonKey, aasdk::proto::enums::ButtonCode::LEFT);
|
||||
this->insertButtonCode(iniConfig, cInputRightButtonKey, aasdk::proto::enums::ButtonCode::RIGHT);
|
||||
this->insertButtonCode(iniConfig, cInputUpButtonKey, aasdk::proto::enums::ButtonCode::UP);
|
||||
this->insertButtonCode(iniConfig, cInputDownButtonKey, aasdk::proto::enums::ButtonCode::DOWN);
|
||||
this->insertButtonCode(iniConfig, cInputScrollWheelButtonKey, aasdk::proto::enums::ButtonCode::SCROLL_WHEEL);
|
||||
this->insertButtonCode(iniConfig, cInputBackButtonKey, aasdk::proto::enums::ButtonCode::BACK);
|
||||
this->insertButtonCode(iniConfig, cInputEnterButtonKey, aasdk::proto::enums::ButtonCode::ENTER);
|
||||
this->insertButtonCode(iniConfig, cInputNavButtonKey, aasdk::proto::enums::ButtonCode::NAVIGATION);
|
||||
this->insertButtonCode(iniConfig, cInputPlayButtonKey, aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_MEDIA_PLAY);
|
||||
this->insertButtonCode(iniConfig, cInputPauseButtonKey, aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_MEDIA_PAUSE);
|
||||
this->insertButtonCode(iniConfig, cInputTogglePlayButtonKey, aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_MEDIA_PLAY_PAUSE);
|
||||
this->insertButtonCode(iniConfig, cInputNextTrackButtonKey, aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_MEDIA_NEXT);
|
||||
this->insertButtonCode(iniConfig, cInputPreviousTrackButtonKey, aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_MEDIA_PREVIOUS);
|
||||
this->insertButtonCode(iniConfig, cInputHomeButtonKey, aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_HOME);
|
||||
this->insertButtonCode(iniConfig, cInputPhoneButtonKey, aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_CALL);
|
||||
this->insertButtonCode(iniConfig, cInputCallEndButtonKey, aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_ENDCALL);
|
||||
this->insertButtonCode(iniConfig, cInputVoiceCommandButtonKey, aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_SEARCH);
|
||||
this->insertButtonCode(iniConfig, cInputLeftButtonKey, aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_DPAD_LEFT);
|
||||
this->insertButtonCode(iniConfig, cInputRightButtonKey, aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_DPAD_RIGHT);
|
||||
this->insertButtonCode(iniConfig, cInputUpButtonKey, aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_DPAD_UP);
|
||||
this->insertButtonCode(iniConfig, cInputDownButtonKey, aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_DPAD_DOWN);
|
||||
this->insertButtonCode(iniConfig, cInputScrollWheelButtonKey, aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_ROTARY_CONTROLLER);
|
||||
this->insertButtonCode(iniConfig, cInputBackButtonKey, aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_BACK);
|
||||
this->insertButtonCode(iniConfig, cInputEnterButtonKey, aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_DPAD_CENTER);
|
||||
this->insertButtonCode(iniConfig, cInputNavButtonKey, aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_NAVIGATION);
|
||||
}
|
||||
|
||||
void Configuration::insertButtonCode(boost::property_tree::ptree& iniConfig, const std::string& buttonCodeKey, aasdk::proto::enums::ButtonCode::Enum buttonCode)
|
||||
void Configuration::insertButtonCode(boost::property_tree::ptree& iniConfig, const std::string& buttonCodeKey, aap_protobuf::service::media::sink::message::KeyCode buttonCode)
|
||||
{
|
||||
if(iniConfig.get<bool>(buttonCodeKey, false))
|
||||
{
|
||||
@ -725,26 +756,26 @@ void Configuration::insertButtonCode(boost::property_tree::ptree& iniConfig, con
|
||||
|
||||
void Configuration::writeButtonCodes(boost::property_tree::ptree& iniConfig)
|
||||
{
|
||||
iniConfig.put<bool>(cInputPlayButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::PLAY) != buttonCodes_.end());
|
||||
iniConfig.put<bool>(cInputPauseButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::PAUSE) != buttonCodes_.end());
|
||||
iniConfig.put<bool>(cInputTogglePlayButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::TOGGLE_PLAY) != buttonCodes_.end());
|
||||
iniConfig.put<bool>(cInputNextTrackButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::NEXT) != buttonCodes_.end());
|
||||
iniConfig.put<bool>(cInputPreviousTrackButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::PREV) != buttonCodes_.end());
|
||||
iniConfig.put<bool>(cInputHomeButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::HOME) != buttonCodes_.end());
|
||||
iniConfig.put<bool>(cInputPhoneButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::PHONE) != buttonCodes_.end());
|
||||
iniConfig.put<bool>(cInputCallEndButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::CALL_END) != buttonCodes_.end());
|
||||
iniConfig.put<bool>(cInputVoiceCommandButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::MICROPHONE_1) != buttonCodes_.end());
|
||||
iniConfig.put<bool>(cInputLeftButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::LEFT) != buttonCodes_.end());
|
||||
iniConfig.put<bool>(cInputRightButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::RIGHT) != buttonCodes_.end());
|
||||
iniConfig.put<bool>(cInputUpButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::UP) != buttonCodes_.end());
|
||||
iniConfig.put<bool>(cInputDownButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::DOWN) != buttonCodes_.end());
|
||||
iniConfig.put<bool>(cInputScrollWheelButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::SCROLL_WHEEL) != buttonCodes_.end());
|
||||
iniConfig.put<bool>(cInputBackButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::BACK) != buttonCodes_.end());
|
||||
iniConfig.put<bool>(cInputEnterButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::ENTER) != buttonCodes_.end());
|
||||
iniConfig.put<bool>(cInputNavButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::NAVIGATION) != buttonCodes_.end());
|
||||
iniConfig.put<bool>(cInputPlayButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_MEDIA_PLAY) != buttonCodes_.end());
|
||||
iniConfig.put<bool>(cInputPauseButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_MEDIA_PAUSE) != buttonCodes_.end());
|
||||
iniConfig.put<bool>(cInputTogglePlayButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_MEDIA_PLAY_PAUSE) != buttonCodes_.end());
|
||||
iniConfig.put<bool>(cInputNextTrackButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_MEDIA_NEXT) != buttonCodes_.end());
|
||||
iniConfig.put<bool>(cInputPreviousTrackButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_MEDIA_PREVIOUS) != buttonCodes_.end());
|
||||
iniConfig.put<bool>(cInputHomeButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_HOME) != buttonCodes_.end());
|
||||
iniConfig.put<bool>(cInputPhoneButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_CALL) != buttonCodes_.end());
|
||||
iniConfig.put<bool>(cInputCallEndButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_ENDCALL) != buttonCodes_.end());
|
||||
iniConfig.put<bool>(cInputVoiceCommandButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_SEARCH) != buttonCodes_.end());
|
||||
iniConfig.put<bool>(cInputLeftButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_DPAD_LEFT) != buttonCodes_.end());
|
||||
iniConfig.put<bool>(cInputRightButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_DPAD_RIGHT) != buttonCodes_.end());
|
||||
iniConfig.put<bool>(cInputUpButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_DPAD_UP) != buttonCodes_.end());
|
||||
iniConfig.put<bool>(cInputDownButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_DPAD_DOWN) != buttonCodes_.end());
|
||||
iniConfig.put<bool>(cInputScrollWheelButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_ROTARY_CONTROLLER) != buttonCodes_.end());
|
||||
iniConfig.put<bool>(cInputBackButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_BACK) != buttonCodes_.end());
|
||||
iniConfig.put<bool>(cInputEnterButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_DPAD_CENTER) != buttonCodes_.end());
|
||||
iniConfig.put<bool>(cInputNavButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_NAVIGATION) != buttonCodes_.end());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -18,13 +18,10 @@
|
||||
|
||||
#include <f1x/openauto/autoapp/Projection/DummyBluetoothDevice.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace projection
|
||||
|
||||
|
||||
|
||||
namespace f1x::openauto::autoapp::projection
|
||||
{
|
||||
|
||||
void DummyBluetoothDevice::stop()
|
||||
@ -37,12 +34,7 @@ bool DummyBluetoothDevice::isPaired(const std::string&) const
|
||||
return false;
|
||||
}
|
||||
|
||||
void DummyBluetoothDevice::pair(const std::string&, PairingPromise::Pointer promise)
|
||||
{
|
||||
promise->reject();
|
||||
}
|
||||
|
||||
std::string DummyBluetoothDevice::getLocalAddress() const
|
||||
std::string DummyBluetoothDevice::getAdapterAddress() const
|
||||
{
|
||||
return "";
|
||||
}
|
||||
@ -53,6 +45,6 @@ bool DummyBluetoothDevice::isAvailable() const
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -43,7 +43,7 @@ void InputDevice::start(IInputDeviceEventHandler& eventHandler)
|
||||
{
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
|
||||
OPENAUTO_LOG(info) << "[InputDevice] start.";
|
||||
OPENAUTO_LOG(info) << "[InputDevice] start()";
|
||||
eventHandler_ = &eventHandler;
|
||||
parent_.installEventFilter(this);
|
||||
}
|
||||
@ -52,7 +52,7 @@ void InputDevice::stop()
|
||||
{
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
|
||||
OPENAUTO_LOG(info) << "[InputDevice] stop.";
|
||||
OPENAUTO_LOG(info) << "[InputDevice] stop()";
|
||||
parent_.removeEventFilter(this);
|
||||
eventHandler_ = nullptr;
|
||||
}
|
||||
@ -83,91 +83,91 @@ bool InputDevice::eventFilter(QObject* obj, QEvent* event)
|
||||
bool InputDevice::handleKeyEvent(QEvent* event, QKeyEvent* key)
|
||||
{
|
||||
auto eventType = event->type() == QEvent::KeyPress ? ButtonEventType::PRESS : ButtonEventType::RELEASE;
|
||||
aasdk::proto::enums::ButtonCode::Enum buttonCode;
|
||||
aap_protobuf::service::media::sink::message::KeyCode buttonCode;
|
||||
WheelDirection wheelDirection = WheelDirection::NONE;
|
||||
|
||||
switch(key->key())
|
||||
{
|
||||
case Qt::Key_Return:
|
||||
case Qt::Key_Enter:
|
||||
buttonCode = aasdk::proto::enums::ButtonCode::ENTER;
|
||||
buttonCode = aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_DPAD_CENTER;
|
||||
break;
|
||||
|
||||
case Qt::Key_Left:
|
||||
buttonCode = aasdk::proto::enums::ButtonCode::LEFT;
|
||||
buttonCode = aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_DPAD_LEFT;
|
||||
break;
|
||||
|
||||
case Qt::Key_Right:
|
||||
buttonCode = aasdk::proto::enums::ButtonCode::RIGHT;
|
||||
buttonCode = aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_DPAD_RIGHT;
|
||||
break;
|
||||
|
||||
case Qt::Key_Up:
|
||||
buttonCode = aasdk::proto::enums::ButtonCode::UP;
|
||||
buttonCode = aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_DPAD_UP;
|
||||
break;
|
||||
|
||||
case Qt::Key_Down:
|
||||
buttonCode = aasdk::proto::enums::ButtonCode::DOWN;
|
||||
buttonCode = aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_DPAD_DOWN;
|
||||
break;
|
||||
|
||||
case Qt::Key_Escape:
|
||||
buttonCode = aasdk::proto::enums::ButtonCode::BACK;
|
||||
buttonCode = aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_BACK;
|
||||
break;
|
||||
|
||||
case Qt::Key_H:
|
||||
buttonCode = aasdk::proto::enums::ButtonCode::HOME;
|
||||
buttonCode = aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_HOME;
|
||||
break;
|
||||
|
||||
case Qt::Key_P:
|
||||
buttonCode = aasdk::proto::enums::ButtonCode::PHONE;
|
||||
buttonCode = aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_CALL;
|
||||
break;
|
||||
|
||||
case Qt::Key_O:
|
||||
buttonCode = aasdk::proto::enums::ButtonCode::CALL_END;
|
||||
buttonCode = aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_ENDCALL;
|
||||
break;
|
||||
|
||||
case Qt::Key_MediaPlay:
|
||||
case Qt::Key_X:
|
||||
buttonCode = aasdk::proto::enums::ButtonCode::PLAY;
|
||||
buttonCode = aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_MEDIA_PLAY;
|
||||
break;
|
||||
|
||||
case Qt::Key_MediaPause:
|
||||
case Qt::Key_C:
|
||||
buttonCode = aasdk::proto::enums::ButtonCode::PAUSE;
|
||||
buttonCode = aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_MEDIA_PAUSE;
|
||||
break;
|
||||
|
||||
case Qt::Key_MediaPrevious:
|
||||
case Qt::Key_V:
|
||||
buttonCode = aasdk::proto::enums::ButtonCode::PREV;
|
||||
buttonCode = aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_MEDIA_PREVIOUS;
|
||||
break;
|
||||
|
||||
case Qt::Key_MediaTogglePlayPause:
|
||||
case Qt::Key_B:
|
||||
buttonCode = aasdk::proto::enums::ButtonCode::TOGGLE_PLAY;
|
||||
buttonCode = aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_MEDIA_PLAY_PAUSE;
|
||||
break;
|
||||
|
||||
case Qt::Key_MediaNext:
|
||||
case Qt::Key_N:
|
||||
buttonCode = aasdk::proto::enums::ButtonCode::NEXT;
|
||||
buttonCode = aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_MEDIA_NEXT;
|
||||
break;
|
||||
|
||||
case Qt::Key_M:
|
||||
buttonCode = aasdk::proto::enums::ButtonCode::MICROPHONE_1;
|
||||
buttonCode = aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_SEARCH;
|
||||
break;
|
||||
|
||||
case Qt::Key_1:
|
||||
wheelDirection = WheelDirection::LEFT;
|
||||
eventType = ButtonEventType::NONE;
|
||||
buttonCode = aasdk::proto::enums::ButtonCode::SCROLL_WHEEL;
|
||||
buttonCode = aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_ROTARY_CONTROLLER;
|
||||
break;
|
||||
|
||||
case Qt::Key_2:
|
||||
wheelDirection = WheelDirection::RIGHT;
|
||||
eventType = ButtonEventType::NONE;
|
||||
buttonCode = aasdk::proto::enums::ButtonCode::SCROLL_WHEEL;
|
||||
buttonCode = aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_ROTARY_CONTROLLER;
|
||||
break;
|
||||
|
||||
case Qt::Key_F:
|
||||
buttonCode = aasdk::proto::enums::ButtonCode::NAVIGATION;
|
||||
buttonCode = aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_NAVIGATION;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -177,7 +177,7 @@ bool InputDevice::handleKeyEvent(QEvent* event, QKeyEvent* key)
|
||||
const auto& buttonCodes = this->getSupportedButtonCodes();
|
||||
if(std::find(buttonCodes.begin(), buttonCodes.end(), buttonCode) != buttonCodes.end())
|
||||
{
|
||||
if(buttonCode != aasdk::proto::enums::ButtonCode::SCROLL_WHEEL || event->type() == QEvent::KeyRelease)
|
||||
if(buttonCode != aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_ROTARY_CONTROLLER || event->type() == QEvent::KeyRelease)
|
||||
{
|
||||
eventHandler_->onButtonEvent({eventType, wheelDirection, buttonCode});
|
||||
}
|
||||
@ -193,18 +193,18 @@ bool InputDevice::handleTouchEvent(QEvent* event)
|
||||
return true;
|
||||
}
|
||||
|
||||
aasdk::proto::enums::TouchAction::Enum type;
|
||||
aap_protobuf::service::inputsource::message::PointerAction type;
|
||||
|
||||
switch(event->type())
|
||||
{
|
||||
case QEvent::MouseButtonPress:
|
||||
type = aasdk::proto::enums::TouchAction::PRESS;
|
||||
type = aap_protobuf::service::inputsource::message::PointerAction::ACTION_DOWN;
|
||||
break;
|
||||
case QEvent::MouseButtonRelease:
|
||||
type = aasdk::proto::enums::TouchAction::RELEASE;
|
||||
type = aap_protobuf::service::inputsource::message::PointerAction::ACTION_UP;
|
||||
break;
|
||||
case QEvent::MouseMove:
|
||||
type = aasdk::proto::enums::TouchAction::DRAG;
|
||||
type = aap_protobuf::service::inputsource::message::PointerAction::ACTION_MOVED;
|
||||
break;
|
||||
default:
|
||||
return true;
|
||||
|
@ -19,221 +19,53 @@
|
||||
#include <QApplication>
|
||||
#include <f1x/openauto/Common/Log.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/LocalBluetoothDevice.hpp>
|
||||
#include <QBluetoothUuid>
|
||||
#include <QtBluetooth>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace projection
|
||||
{
|
||||
namespace f1x::openauto::autoapp::projection {
|
||||
|
||||
LocalBluetoothDevice::LocalBluetoothDevice()
|
||||
{
|
||||
LocalBluetoothDevice::LocalBluetoothDevice(const QString &adapterAddress, QObject *parent) : QObject(parent) {
|
||||
qRegisterMetaType<IBluetoothDevice::PairingPromise::Pointer>("PairingPromise::Pointer");
|
||||
|
||||
this->moveToThread(QApplication::instance()->thread());
|
||||
connect(this, &LocalBluetoothDevice::startPairing, this, &LocalBluetoothDevice::onStartPairing, Qt::QueuedConnection);
|
||||
QMetaObject::invokeMethod(this, "createBluetoothLocalDevice", Qt::BlockingQueuedConnection);
|
||||
}
|
||||
|
||||
void LocalBluetoothDevice::createBluetoothLocalDevice()
|
||||
{
|
||||
OPENAUTO_LOG(debug) << "[LocalBluetoothDevice] create.";
|
||||
QMetaObject::invokeMethod(this, "createBluetoothLocalDevice", Qt::BlockingQueuedConnection,
|
||||
Q_ARG(QString, adapterAddress));
|
||||
|
||||
localDevice_ = std::make_unique<QBluetoothLocalDevice>(QBluetoothAddress());
|
||||
}
|
||||
|
||||
connect(localDevice_.get(), &QBluetoothLocalDevice::pairingDisplayConfirmation, this, &LocalBluetoothDevice::onPairingDisplayConfirmation);
|
||||
connect(localDevice_.get(), &QBluetoothLocalDevice::pairingDisplayPinCode, this, &LocalBluetoothDevice::onPairingDisplayPinCode);
|
||||
connect(localDevice_.get(), &QBluetoothLocalDevice::pairingFinished, this, &LocalBluetoothDevice::onPairingFinished);
|
||||
connect(localDevice_.get(), &QBluetoothLocalDevice::error, this, &LocalBluetoothDevice::onError);
|
||||
connect(localDevice_.get(), &QBluetoothLocalDevice::hostModeStateChanged, this, &LocalBluetoothDevice::onHostModeStateChanged);
|
||||
void LocalBluetoothDevice::createBluetoothLocalDevice(const QString &adapterAddress) {
|
||||
OPENAUTO_LOG(info) << "[LocalBluetoothDevice] create.";
|
||||
|
||||
localDevice_->powerOn();
|
||||
localDevice_->setHostMode(QBluetoothLocalDevice::HostDiscoverable);
|
||||
//
|
||||
// rfcommServer_ = std::make_unique<QBluetoothServer>(QBluetoothServiceInfo::RfcommProtocol, this);
|
||||
// connect(rfcommServer_.get(), &QBluetoothServer::newConnection, this, &LocalBluetoothDevice::onClientConnected, Qt::QueuedConnection);
|
||||
// if (rfcommServer_->listen(localDevice_->address())) {
|
||||
// OPENAUTO_LOG(debug) << "Listening for rfcomm connections on port " << rfcommServer_->serverPort();
|
||||
// }
|
||||
// else {
|
||||
// OPENAUTO_LOG(debug) << "Could not start rfcomm";
|
||||
// }
|
||||
//
|
||||
// //"4de17a00-52cb-11e6-bdf4-0800200c9a66";
|
||||
// //"669a0c20-0008-f4bd-e611-cb52007ae14d";
|
||||
// const QBluetoothUuid serviceUuid(QLatin1String("4de17a00-52cb-11e6-bdf4-0800200c9a66"));
|
||||
//
|
||||
// QBluetoothServiceInfo::Sequence classId;
|
||||
// classId << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::SerialPort));
|
||||
// serviceInfo_.setAttribute(QBluetoothServiceInfo::BluetoothProfileDescriptorList, classId);
|
||||
// classId.prepend(QVariant::fromValue(serviceUuid));
|
||||
// serviceInfo_.setAttribute(QBluetoothServiceInfo::ServiceClassIds, classId);
|
||||
// serviceInfo_.setAttribute(QBluetoothServiceInfo::ServiceName, "OpenAuto Bluetooth Service");
|
||||
// serviceInfo_.setAttribute(QBluetoothServiceInfo::ServiceDescription, "AndroidAuto WiFi projection automatic setup");
|
||||
// serviceInfo_.setAttribute(QBluetoothServiceInfo::ServiceProvider, "f1xstudio.com");
|
||||
// serviceInfo_.setServiceUuid(serviceUuid);
|
||||
//
|
||||
// QBluetoothServiceInfo::Sequence publicBrowse;
|
||||
// publicBrowse << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::PublicBrowseGroup));
|
||||
// serviceInfo_.setAttribute(QBluetoothServiceInfo::BrowseGroupList, publicBrowse);
|
||||
//
|
||||
// QBluetoothServiceInfo::Sequence protocolDescriptorList;
|
||||
// QBluetoothServiceInfo::Sequence protocol;
|
||||
// protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::L2cap));
|
||||
// protocolDescriptorList.append(QVariant::fromValue(protocol));
|
||||
// protocol.clear();
|
||||
// protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::Rfcomm))
|
||||
// << QVariant::fromValue(quint8(rfcommServer_->serverPort()));
|
||||
// protocolDescriptorList.append(QVariant::fromValue(protocol));
|
||||
// serviceInfo_.setAttribute(QBluetoothServiceInfo::ProtocolDescriptorList, protocolDescriptorList);
|
||||
// serviceInfo_.registerService(localDevice_->address());
|
||||
}
|
||||
|
||||
void LocalBluetoothDevice::stop()
|
||||
{
|
||||
QBluetoothAddress address(adapterAddress);
|
||||
localDevice_ = std::make_unique<QBluetoothLocalDevice>(address);
|
||||
|
||||
// Pairing signals are being handled by btservice
|
||||
|
||||
}
|
||||
|
||||
void LocalBluetoothDevice::stop() {
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
|
||||
if(pairingPromise_ != nullptr)
|
||||
{
|
||||
pairingPromise_->reject();
|
||||
pairingPromise_.reset();
|
||||
pairingAddress_ = QBluetoothAddress();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool LocalBluetoothDevice::isPaired(const std::string& address) const
|
||||
{
|
||||
bool LocalBluetoothDevice::isPaired(const std::string &address) const {
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
|
||||
return localDevice_->pairingStatus(QBluetoothAddress(QString::fromStdString(address))) != QBluetoothLocalDevice::Unpaired;
|
||||
}
|
||||
return localDevice_->pairingStatus(QBluetoothAddress(QString::fromStdString(address))) !=
|
||||
QBluetoothLocalDevice::Unpaired;
|
||||
}
|
||||
|
||||
void LocalBluetoothDevice::pair(const std::string& address, PairingPromise::Pointer promise)
|
||||
{
|
||||
emit startPairing(QString::fromStdString(address), std::move(promise));
|
||||
}
|
||||
|
||||
std::string LocalBluetoothDevice::getLocalAddress() const
|
||||
{
|
||||
std::string LocalBluetoothDevice::getAdapterAddress() const {
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
return localDevice_->isValid() ? localDevice_->address().toString().toStdString() : "";
|
||||
}
|
||||
}
|
||||
|
||||
bool LocalBluetoothDevice::isAvailable() const
|
||||
{
|
||||
bool LocalBluetoothDevice::isAvailable() const {
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
return localDevice_->isValid();
|
||||
}
|
||||
}
|
||||
|
||||
void LocalBluetoothDevice::onStartPairing(const QString& address, PairingPromise::Pointer promise)
|
||||
{
|
||||
OPENAUTO_LOG(debug) << "[LocalBluetoothDevice] onStartPairing, address: " << address.toStdString();
|
||||
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
|
||||
if(!localDevice_->isValid())
|
||||
{
|
||||
promise->reject();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(pairingPromise_ != nullptr)
|
||||
{
|
||||
pairingPromise_->reject();
|
||||
}
|
||||
|
||||
pairingAddress_ = QBluetoothAddress(address);
|
||||
pairingPromise_ = std::move(promise);
|
||||
localDevice_->requestPairing(pairingAddress_, QBluetoothLocalDevice::AuthorizedPaired);
|
||||
}
|
||||
}
|
||||
|
||||
void LocalBluetoothDevice::onPairingDisplayConfirmation(const QBluetoothAddress &address, QString pin)
|
||||
{
|
||||
OPENAUTO_LOG(debug) << "[LocalBluetoothDevice] onPairingDisplayConfirmation, address: " << address.toString().toStdString()
|
||||
<< ", pin: " << pin.toStdString();
|
||||
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
localDevice_->pairingConfirmation(address == pairingAddress_);
|
||||
}
|
||||
|
||||
void LocalBluetoothDevice::onPairingDisplayPinCode(const QBluetoothAddress &address, QString pin)
|
||||
{
|
||||
OPENAUTO_LOG(debug) << "[LocalBluetoothDevice] onPairingDisplayPinCode, address: " << address.toString().toStdString()
|
||||
<< ", pin: " << pin.toStdString();
|
||||
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
localDevice_->pairingConfirmation(address == pairingAddress_);
|
||||
}
|
||||
|
||||
void LocalBluetoothDevice::onPairingFinished(const QBluetoothAddress &address, QBluetoothLocalDevice::Pairing pairing)
|
||||
{
|
||||
OPENAUTO_LOG(debug) << "[LocalBluetoothDevice] onPairingDisplayPinCode, address: " << address.toString().toStdString()
|
||||
<< ", pin: " << pairing;
|
||||
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
|
||||
if(address == pairingAddress_)
|
||||
{
|
||||
if(pairing != QBluetoothLocalDevice::Unpaired)
|
||||
{
|
||||
pairingPromise_->resolve();
|
||||
}
|
||||
else
|
||||
{
|
||||
pairingPromise_->reject();
|
||||
}
|
||||
|
||||
pairingPromise_.reset();
|
||||
pairingAddress_ = QBluetoothAddress();
|
||||
}
|
||||
}
|
||||
|
||||
void LocalBluetoothDevice::onError(QBluetoothLocalDevice::Error error)
|
||||
{
|
||||
OPENAUTO_LOG(debug) << "[LocalBluetoothDevice] onError, error: " << error;
|
||||
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
|
||||
if(pairingPromise_ != nullptr)
|
||||
{
|
||||
pairingPromise_->reject();
|
||||
pairingPromise_.reset();
|
||||
pairingAddress_ = QBluetoothAddress();
|
||||
}
|
||||
}
|
||||
|
||||
void LocalBluetoothDevice::onHostModeStateChanged(QBluetoothLocalDevice::HostMode state)
|
||||
{
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
|
||||
if(state == QBluetoothLocalDevice::HostPoweredOff && pairingPromise_ != nullptr)
|
||||
{
|
||||
pairingPromise_->reject();
|
||||
pairingPromise_.reset();
|
||||
pairingAddress_ = QBluetoothAddress();
|
||||
}
|
||||
}
|
||||
|
||||
void LocalBluetoothDevice::onClientConnected() {
|
||||
auto socket = rfcommServer_->nextPendingConnection();
|
||||
|
||||
if(socket != nullptr)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[BluetoothServer] rfcomm client connected, peer name: " << socket->peerName().toStdString();
|
||||
}
|
||||
else
|
||||
{
|
||||
OPENAUTO_LOG(error) << "[BluetoothServer] received null socket during client connection.";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ bool OMXVideoOutput::open()
|
||||
{
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
|
||||
OPENAUTO_LOG(info) << "[OMXVideoOutput] open.";
|
||||
OPENAUTO_LOG(debug) << "[OMXVideoOutput] open.";
|
||||
|
||||
bcm_host_init();
|
||||
if(OMX_Init() != OMX_ErrorNone)
|
||||
@ -102,7 +102,7 @@ bool OMXVideoOutput::init()
|
||||
{
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
|
||||
OPENAUTO_LOG(info) << "[OMXVideoOutput] init, state: " << isActive_;
|
||||
OPENAUTO_LOG(debug) << "[OMXVideoOutput] init, state: " << isActive_;
|
||||
ilclient_change_component_state(components_[VideoComponent::DECODER], OMX_StateExecuting);
|
||||
|
||||
return this->setupDisplayRegion();
|
||||
@ -179,7 +179,7 @@ void OMXVideoOutput::write(uint64_t timestamp, const aasdk::common::DataConstBuf
|
||||
|
||||
void OMXVideoOutput::stop()
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[OMXVideoOutput] stop.";
|
||||
OPENAUTO_LOG(debug) << "[OMXVideoOutput] stop.";
|
||||
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
|
||||
|
@ -49,7 +49,7 @@ QtAudioInput::QtAudioInput(uint32_t channelCount, uint32_t sampleSize, uint32_t
|
||||
|
||||
void QtAudioInput::createAudioInput()
|
||||
{
|
||||
OPENAUTO_LOG(debug) << "[AudioInput] create.";
|
||||
OPENAUTO_LOG(info) << "[AudioInput] createAudioInput()";
|
||||
audioInput_ = (std::make_unique<QAudioInput>(QAudioDeviceInfo::defaultInputDevice(), audioFormat_));
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ QtAudioOutput::QtAudioOutput(uint32_t channelCount, uint32_t sampleSize, uint32_
|
||||
|
||||
void QtAudioOutput::createAudioOutput()
|
||||
{
|
||||
OPENAUTO_LOG(debug) << "[QtAudioOutput] create.";
|
||||
OPENAUTO_LOG(info) << "[QtAudioOutput] createAudioOutput()";
|
||||
audioOutput_ = std::make_unique<QAudioOutput>(QAudioDeviceInfo::defaultOutputDevice(), audioFormat_);
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ QtVideoOutput::QtVideoOutput(configuration::IConfiguration::Pointer configuratio
|
||||
|
||||
void QtVideoOutput::createVideoOutput()
|
||||
{
|
||||
OPENAUTO_LOG(debug) << "[QtVideoOutput] create.";
|
||||
OPENAUTO_LOG(info) << "[QtVideoOutput] createVideoOutput()";
|
||||
videoWidget_ = std::make_unique<QVideoWidget>();
|
||||
mediaPlayer_ = std::make_unique<QMediaPlayer>(nullptr, QMediaPlayer::StreamPlayback);
|
||||
}
|
||||
@ -78,6 +78,8 @@ void QtVideoOutput::onStartPlayback()
|
||||
mediaPlayer_->setVideoOutput(videoWidget_.get());
|
||||
mediaPlayer_->setMedia(QMediaContent(), &videoBuffer_);
|
||||
mediaPlayer_->play();
|
||||
|
||||
// TODO: This only outputs a line if there's an error - FIXME - Output a proper status instead
|
||||
OPENAUTO_LOG(debug) << "Player error state -> " << mediaPlayer_->errorString().toStdString();
|
||||
}
|
||||
|
||||
|
@ -1,64 +0,0 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <f1x/openauto/autoapp/Projection/RemoteBluetoothDevice.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace projection
|
||||
{
|
||||
|
||||
RemoteBluetoothDevice::RemoteBluetoothDevice(const std::string& address)
|
||||
: address_(address)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RemoteBluetoothDevice::stop()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool RemoteBluetoothDevice::isPaired(const std::string&) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void RemoteBluetoothDevice::pair(const std::string&, PairingPromise::Pointer promise)
|
||||
{
|
||||
promise->resolve();
|
||||
}
|
||||
|
||||
std::string RemoteBluetoothDevice::getLocalAddress() const
|
||||
{
|
||||
return address_;
|
||||
}
|
||||
|
||||
bool RemoteBluetoothDevice::isAvailable() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -60,6 +60,7 @@ bool RtAudioOutput::open()
|
||||
}
|
||||
catch(const RtAudioError& e)
|
||||
{
|
||||
// TODO: Later version of RtAudio uses a different mechanism - FIXME - support new versions
|
||||
OPENAUTO_LOG(error) << "[RtAudioOutput] Failed to open audio output, what: " << e.what();
|
||||
}
|
||||
}
|
||||
|
@ -16,44 +16,36 @@
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <f1x/openauto/Common/Log.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/VideoOutput.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace projection
|
||||
{
|
||||
namespace f1x {
|
||||
namespace openauto {
|
||||
namespace autoapp {
|
||||
namespace projection {
|
||||
|
||||
VideoOutput::VideoOutput(configuration::IConfiguration::Pointer configuration)
|
||||
: configuration_(std::move(configuration))
|
||||
{
|
||||
VideoOutput::VideoOutput(configuration::IConfiguration::Pointer configuration)
|
||||
: configuration_(std::move(configuration)) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
aasdk::proto::enums::VideoFPS::Enum VideoOutput::getVideoFPS() const
|
||||
{
|
||||
return configuration_->getVideoFPS();
|
||||
}
|
||||
aap_protobuf::service::media::sink::message::VideoFrameRateType VideoOutput::getVideoFPS() const {
|
||||
return configuration_->getVideoFPS();
|
||||
}
|
||||
|
||||
aasdk::proto::enums::VideoResolution::Enum VideoOutput::getVideoResolution() const
|
||||
{
|
||||
return configuration_->getVideoResolution();
|
||||
}
|
||||
aap_protobuf::service::media::sink::message::VideoCodecResolutionType VideoOutput::getVideoResolution() const {
|
||||
return configuration_->getVideoResolution();
|
||||
}
|
||||
|
||||
size_t VideoOutput::getScreenDPI() const
|
||||
{
|
||||
return configuration_->getScreenDPI();
|
||||
}
|
||||
size_t VideoOutput::getScreenDPI() const {
|
||||
return configuration_->getScreenDPI();
|
||||
}
|
||||
|
||||
QRect VideoOutput::getVideoMargins() const
|
||||
{
|
||||
return configuration_->getVideoMargins();
|
||||
}
|
||||
QRect VideoOutput::getVideoMargins() const {
|
||||
return configuration_->getVideoMargins();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,310 +20,343 @@
|
||||
#include <f1x/openauto/autoapp/Service/AndroidAutoEntity.hpp>
|
||||
#include <f1x/openauto/Common/Log.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace service
|
||||
{
|
||||
namespace f1x {
|
||||
namespace openauto {
|
||||
namespace autoapp {
|
||||
namespace service {
|
||||
|
||||
AndroidAutoEntity::AndroidAutoEntity(boost::asio::io_service& ioService,
|
||||
aasdk::messenger::ICryptor::Pointer cryptor,
|
||||
aasdk::transport::ITransport::Pointer transport,
|
||||
aasdk::messenger::IMessenger::Pointer messenger,
|
||||
configuration::IConfiguration::Pointer configuration,
|
||||
ServiceList serviceList,
|
||||
IPinger::Pointer pinger)
|
||||
: strand_(ioService)
|
||||
, cryptor_(std::move(cryptor))
|
||||
, transport_(std::move(transport))
|
||||
, messenger_(std::move(messenger))
|
||||
, controlServiceChannel_(std::make_shared<aasdk::channel::control::ControlServiceChannel>(strand_, messenger_))
|
||||
, configuration_(std::move(configuration))
|
||||
, serviceList_(std::move(serviceList))
|
||||
, pinger_(std::move(pinger))
|
||||
, eventHandler_(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
AndroidAutoEntity::~AndroidAutoEntity()
|
||||
{
|
||||
OPENAUTO_LOG(debug) << "[AndroidAutoEntity] destroy.";
|
||||
}
|
||||
|
||||
void AndroidAutoEntity::start(IAndroidAutoEntityEventHandler& eventHandler)
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this(), eventHandler = &eventHandler]() {
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] start.";
|
||||
|
||||
eventHandler_ = eventHandler;
|
||||
std::for_each(serviceList_.begin(), serviceList_.end(), std::bind(&IService::start, std::placeholders::_1));
|
||||
//this->schedulePing();
|
||||
|
||||
auto versionRequestPromise = aasdk::channel::SendPromise::defer(strand_);
|
||||
versionRequestPromise->then([]() {}, std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
controlServiceChannel_->sendVersionRequest(std::move(versionRequestPromise));
|
||||
controlServiceChannel_->receive(this->shared_from_this());
|
||||
});
|
||||
}
|
||||
|
||||
void AndroidAutoEntity::stop()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] stop.";
|
||||
|
||||
try {
|
||||
eventHandler_ = nullptr;
|
||||
std::for_each(serviceList_.begin(), serviceList_.end(), std::bind(&IService::stop, std::placeholders::_1));
|
||||
//pinger_->cancel();
|
||||
messenger_->stop();
|
||||
transport_->stop();
|
||||
cryptor_->deinit();
|
||||
} catch (...) {
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] exception in stop.";
|
||||
AndroidAutoEntity::AndroidAutoEntity(boost::asio::io_service &ioService,
|
||||
aasdk::messenger::ICryptor::Pointer cryptor,
|
||||
aasdk::transport::ITransport::Pointer transport,
|
||||
aasdk::messenger::IMessenger::Pointer messenger,
|
||||
configuration::IConfiguration::Pointer configuration,
|
||||
ServiceList serviceList,
|
||||
IPinger::Pointer pinger)
|
||||
: strand_(ioService), cryptor_(std::move(cryptor)), transport_(std::move(transport)),
|
||||
messenger_(std::move(messenger)), controlServiceChannel_(
|
||||
std::make_shared<aasdk::channel::control::ControlServiceChannel>(strand_, messenger_)),
|
||||
configuration_(std::move(configuration)), serviceList_(std::move(serviceList)),
|
||||
pinger_(std::move(pinger)), eventHandler_(nullptr) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void AndroidAutoEntity::pause()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] pause.";
|
||||
|
||||
try {
|
||||
std::for_each(serviceList_.begin(), serviceList_.end(), std::bind(&IService::pause, std::placeholders::_1));
|
||||
} catch (...) {
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] exception in pause.";
|
||||
AndroidAutoEntity::~AndroidAutoEntity() {
|
||||
OPENAUTO_LOG(debug) << "[AndroidAutoEntity] destroy.";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void AndroidAutoEntity::resume()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] resume.";
|
||||
void AndroidAutoEntity::start(IAndroidAutoEntityEventHandler &eventHandler) {
|
||||
strand_.dispatch([this, self = this->shared_from_this(), eventHandler = &eventHandler]() {
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] start()";
|
||||
|
||||
try {
|
||||
std::for_each(serviceList_.begin(), serviceList_.end(), std::bind(&IService::resume, std::placeholders::_1));
|
||||
} catch (...) {
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] exception in resume.";
|
||||
}
|
||||
});
|
||||
}
|
||||
eventHandler_ = eventHandler;
|
||||
std::for_each(serviceList_.begin(), serviceList_.end(), std::bind(&IService::start, std::placeholders::_1));
|
||||
|
||||
void AndroidAutoEntity::onVersionResponse(uint16_t majorCode, uint16_t minorCode, aasdk::proto::enums::VersionResponseStatus::Enum status)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] version response, version: " << majorCode
|
||||
<< "." << minorCode
|
||||
<< ", status: " << status;
|
||||
auto versionRequestPromise = aasdk::channel::SendPromise::defer(strand_);
|
||||
versionRequestPromise->then([]() { }, std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(),
|
||||
std::placeholders::_1));
|
||||
|
||||
if(status == aasdk::proto::enums::VersionResponseStatus::MISMATCH)
|
||||
{
|
||||
OPENAUTO_LOG(error) << "[AndroidAutoEntity] version mismatch.";
|
||||
this->triggerQuit();
|
||||
}
|
||||
else
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] Begin handshake.";
|
||||
|
||||
try
|
||||
{
|
||||
cryptor_->doHandshake();
|
||||
|
||||
auto handshakePromise = aasdk::channel::SendPromise::defer(strand_);
|
||||
handshakePromise->then([]() {}, std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
controlServiceChannel_->sendHandshake(cryptor_->readHandshakeBuffer(), std::move(handshakePromise));
|
||||
OPENAUTO_LOG(debug) << "[AndroidAutoEntity] Send Version Request.";
|
||||
controlServiceChannel_->sendVersionRequest(std::move(versionRequestPromise));
|
||||
controlServiceChannel_->receive(this->shared_from_this());
|
||||
}
|
||||
catch(const aasdk::error::Error& e)
|
||||
{
|
||||
this->onChannelError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AndroidAutoEntity::onHandshake(const aasdk::common::DataConstBuffer& payload)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] Handshake, size: " << payload.size;
|
||||
|
||||
try
|
||||
{
|
||||
cryptor_->writeHandshakeBuffer(payload);
|
||||
|
||||
if(!cryptor_->doHandshake())
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] continue handshake.";
|
||||
|
||||
auto handshakePromise = aasdk::channel::SendPromise::defer(strand_);
|
||||
handshakePromise->then([]() {}, std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
controlServiceChannel_->sendHandshake(cryptor_->readHandshakeBuffer(), std::move(handshakePromise));
|
||||
}
|
||||
else
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] Auth completed.";
|
||||
|
||||
aasdk::proto::messages::AuthCompleteIndication authCompleteIndication;
|
||||
authCompleteIndication.set_status(aasdk::proto::enums::Status::OK);
|
||||
|
||||
auto authCompletePromise = aasdk::channel::SendPromise::defer(strand_);
|
||||
authCompletePromise->then([]() {}, std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
controlServiceChannel_->sendAuthComplete(authCompleteIndication, std::move(authCompletePromise));
|
||||
});
|
||||
}
|
||||
|
||||
controlServiceChannel_->receive(this->shared_from_this());
|
||||
}
|
||||
catch(const aasdk::error::Error& e)
|
||||
{
|
||||
this->onChannelError(e);
|
||||
}
|
||||
}
|
||||
void AndroidAutoEntity::stop() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] stop()";
|
||||
|
||||
void AndroidAutoEntity::onServiceDiscoveryRequest(const aasdk::proto::messages::ServiceDiscoveryRequest& request)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] Discovery request, device name: " << request.device_name()
|
||||
<< ", brand: " << request.device_brand();
|
||||
try {
|
||||
eventHandler_ = nullptr;
|
||||
std::for_each(serviceList_.begin(), serviceList_.end(),
|
||||
std::bind(&IService::stop, std::placeholders::_1));
|
||||
|
||||
aasdk::proto::messages::ServiceDiscoveryResponse serviceDiscoveryResponse;
|
||||
serviceDiscoveryResponse.mutable_channels()->Reserve(256);
|
||||
serviceDiscoveryResponse.set_head_unit_name("Crankshaft-NG");
|
||||
serviceDiscoveryResponse.set_car_model("Universal");
|
||||
serviceDiscoveryResponse.set_car_year("2018");
|
||||
serviceDiscoveryResponse.set_car_serial("20180301");
|
||||
serviceDiscoveryResponse.set_left_hand_drive_vehicle(configuration_->getHandednessOfTrafficType() == configuration::HandednessOfTrafficType::LEFT_HAND_DRIVE);
|
||||
serviceDiscoveryResponse.set_headunit_manufacturer("f1x");
|
||||
serviceDiscoveryResponse.set_headunit_model("Crankshaft-NG Autoapp");
|
||||
serviceDiscoveryResponse.set_sw_build("1");
|
||||
serviceDiscoveryResponse.set_sw_version("1.0");
|
||||
serviceDiscoveryResponse.set_can_play_native_media_during_vr(false);
|
||||
serviceDiscoveryResponse.set_hide_clock(!configuration_->showClock());
|
||||
messenger_->stop();
|
||||
transport_->stop();
|
||||
cryptor_->deinit();
|
||||
} catch (...) {
|
||||
OPENAUTO_LOG(error) << "[AndroidAutoEntity] stop() - exception when stopping.";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
std::for_each(serviceList_.begin(), serviceList_.end(), std::bind(&IService::fillFeatures, std::placeholders::_1, std::ref(serviceDiscoveryResponse)));
|
||||
void AndroidAutoEntity::pause() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] pause()";
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
controlServiceChannel_->sendServiceDiscoveryResponse(serviceDiscoveryResponse, std::move(promise));
|
||||
controlServiceChannel_->receive(this->shared_from_this());
|
||||
}
|
||||
try {
|
||||
std::for_each(serviceList_.begin(), serviceList_.end(),
|
||||
std::bind(&IService::pause, std::placeholders::_1));
|
||||
} catch (...) {
|
||||
OPENAUTO_LOG(error) << "[AndroidAutoEntity] pause() - exception when pausing.";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void AndroidAutoEntity::onAudioFocusRequest(const aasdk::proto::messages::AudioFocusRequest& request)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] requested audio focus, type: " << request.audio_focus_type();
|
||||
void AndroidAutoEntity::resume() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] resume()";
|
||||
|
||||
aasdk::proto::enums::AudioFocusState::Enum audioFocusState =
|
||||
request.audio_focus_type() == aasdk::proto::enums::AudioFocusType::RELEASE ? aasdk::proto::enums::AudioFocusState::LOSS
|
||||
: aasdk::proto::enums::AudioFocusState::GAIN;
|
||||
try {
|
||||
std::for_each(serviceList_.begin(), serviceList_.end(),
|
||||
std::bind(&IService::resume, std::placeholders::_1));
|
||||
} catch (...) {
|
||||
OPENAUTO_LOG(error) << "[AndroidAutoEntity] resume() exception when resuming.";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] audio focus state: " << audioFocusState;
|
||||
void AndroidAutoEntity::onVersionResponse(uint16_t majorCode, uint16_t minorCode,
|
||||
aap_protobuf::shared::MessageStatus status) {
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] onVersionResponse()";
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] Version Received: " << majorCode << "." << minorCode
|
||||
<< ", with status: " << status;
|
||||
|
||||
aasdk::proto::messages::AudioFocusResponse response;
|
||||
response.set_audio_focus_state(audioFocusState);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
controlServiceChannel_->sendAudioFocusResponse(response, std::move(promise));
|
||||
controlServiceChannel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void AndroidAutoEntity::onShutdownRequest(const aasdk::proto::messages::ShutdownRequest& request)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] Shutdown request, reason: " << request.reason();
|
||||
|
||||
aasdk::proto::messages::ShutdownResponse response;
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then(std::bind(&AndroidAutoEntity::triggerQuit, this->shared_from_this()),
|
||||
std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
|
||||
controlServiceChannel_->sendShutdownResponse(response, std::move(promise));
|
||||
}
|
||||
|
||||
void AndroidAutoEntity::onPingRequest(const aasdk::proto::messages::PingRequest& request)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] ping request ";
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
controlServiceChannel_->sendPingRequest(request, std::move(promise));
|
||||
}
|
||||
|
||||
void AndroidAutoEntity::onVoiceSessionRequest(const aasdk::proto::messages::VoiceSessionRequest& request)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] onVoiceSessionRequest()";
|
||||
controlServiceChannel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void AndroidAutoEntity::onShutdownResponse(const aasdk::proto::messages::ShutdownResponse&)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] Shutdown response ";
|
||||
this->triggerQuit();
|
||||
}
|
||||
|
||||
void AndroidAutoEntity::onNavigationFocusRequest(const aasdk::proto::messages::NavigationFocusRequest& request)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] navigation focus request, type: " << request.type();
|
||||
|
||||
aasdk::proto::messages::NavigationFocusResponse response;
|
||||
response.set_type(2);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
controlServiceChannel_->sendNavigationFocusResponse(response, std::move(promise));
|
||||
controlServiceChannel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void AndroidAutoEntity::onPingResponse(const aasdk::proto::messages::PingResponse& response)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] Ping response, timestamp: " << response.timestamp();
|
||||
pinger_->pong();
|
||||
controlServiceChannel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void AndroidAutoEntity::onChannelError(const aasdk::error::Error& e)
|
||||
{
|
||||
OPENAUTO_LOG(error) << "[AndroidAutoEntity] channel error: " << e.what();
|
||||
this->triggerQuit();
|
||||
}
|
||||
|
||||
void AndroidAutoEntity::triggerQuit()
|
||||
{
|
||||
if(eventHandler_ != nullptr)
|
||||
{
|
||||
eventHandler_->onAndroidAutoQuit();
|
||||
}
|
||||
}
|
||||
|
||||
void AndroidAutoEntity::schedulePing()
|
||||
{
|
||||
auto promise = IPinger::Promise::defer(strand_);
|
||||
promise->then([this, self = this->shared_from_this()]() {
|
||||
this->sendPing();
|
||||
this->schedulePing();
|
||||
},
|
||||
[this, self = this->shared_from_this()](auto error) {
|
||||
if(error != aasdk::error::ErrorCode::OPERATION_ABORTED &&
|
||||
error != aasdk::error::ErrorCode::OPERATION_IN_PROGRESS)
|
||||
{
|
||||
OPENAUTO_LOG(error) << "[AndroidAutoEntity] ping timer exceeded.";
|
||||
if (status == aap_protobuf::shared::MessageStatus::STATUS_NO_COMPATIBLE_VERSION) {
|
||||
OPENAUTO_LOG(error) << "[AndroidAutoEntity] Version mismatch.";
|
||||
this->triggerQuit();
|
||||
} else {
|
||||
OPENAUTO_LOG(debug) << "[AndroidAutoEntity] Version matches.";
|
||||
|
||||
try {
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] Beginning SSL handshake.";
|
||||
cryptor_->doHandshake();
|
||||
|
||||
auto handshakePromise = aasdk::channel::SendPromise::defer(strand_);
|
||||
handshakePromise->then([]() { }, std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(),
|
||||
std::placeholders::_1));
|
||||
controlServiceChannel_->sendHandshake(cryptor_->readHandshakeBuffer(), std::move(handshakePromise));
|
||||
controlServiceChannel_->receive(this->shared_from_this());
|
||||
}
|
||||
catch (const aasdk::error::Error &e) {
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] Handshake Error.";
|
||||
this->onChannelError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
pinger_->ping(std::move(promise));
|
||||
}
|
||||
void AndroidAutoEntity::onHandshake(const aasdk::common::DataConstBuffer &payload) {
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] onHandshake()";
|
||||
OPENAUTO_LOG(debug) << "[AndroidAutoEntity] Payload size: " << payload.size;
|
||||
|
||||
void AndroidAutoEntity::sendPing()
|
||||
{
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
try {
|
||||
cryptor_->writeHandshakeBuffer(payload);
|
||||
|
||||
aasdk::proto::messages::PingRequest request;
|
||||
auto timestamp = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now().time_since_epoch());
|
||||
request.set_timestamp(timestamp.count());
|
||||
controlServiceChannel_->sendPingRequest(request, std::move(promise));
|
||||
}
|
||||
if (!cryptor_->doHandshake()) {
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] Re-attempting handshake.";
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
auto handshakePromise = aasdk::channel::SendPromise::defer(strand_);
|
||||
handshakePromise->then([]() {}, std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(),
|
||||
std::placeholders::_1));
|
||||
controlServiceChannel_->sendHandshake(cryptor_->readHandshakeBuffer(), std::move(handshakePromise));
|
||||
} else {
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] Handshake completed.";
|
||||
|
||||
aap_protobuf::service::control::message::AuthResponse authCompleteIndication;
|
||||
authCompleteIndication.set_status(aap_protobuf::shared::MessageStatus::STATUS_SUCCESS);
|
||||
|
||||
auto authCompletePromise = aasdk::channel::SendPromise::defer(strand_);
|
||||
authCompletePromise->then([]() {}, std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(),
|
||||
std::placeholders::_1));
|
||||
controlServiceChannel_->sendAuthComplete(authCompleteIndication, std::move(authCompletePromise));
|
||||
}
|
||||
|
||||
controlServiceChannel_->receive(this->shared_from_this());
|
||||
}
|
||||
catch (const aasdk::error::Error &e) {
|
||||
OPENAUTO_LOG(error) << "[AndroidAutoEntity] Error during handshake";
|
||||
this->onChannelError(e);
|
||||
}
|
||||
}
|
||||
|
||||
void AndroidAutoEntity::onServiceDiscoveryRequest(
|
||||
const aap_protobuf::service::control::message::ServiceDiscoveryRequest &request) {
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] onServiceDiscoveryRequest()";
|
||||
OPENAUTO_LOG(debug) << "[AndroidAutoEntity] Type: " << request.label_text() << ", Model: "
|
||||
<< request.device_name();
|
||||
|
||||
aap_protobuf::service::control::message::ServiceDiscoveryResponse serviceDiscoveryResponse;
|
||||
serviceDiscoveryResponse.mutable_channels()->Reserve(256);
|
||||
serviceDiscoveryResponse.set_driver_position(aap_protobuf::service::control::message::DriverPosition::DRIVER_POSITION_RIGHT);
|
||||
serviceDiscoveryResponse.set_can_play_native_media_during_vr(false);
|
||||
serviceDiscoveryResponse.set_display_name("Crankshaft-NG");
|
||||
serviceDiscoveryResponse.set_probe_for_support(false);
|
||||
|
||||
auto *connectionConfiguration = serviceDiscoveryResponse.mutable_connection_configuration();
|
||||
|
||||
auto *pingConfiguration = connectionConfiguration->mutable_ping_configuration();
|
||||
pingConfiguration->set_tracked_ping_count(5);
|
||||
pingConfiguration->set_timeout_ms(3000);
|
||||
pingConfiguration->set_interval_ms(1000);
|
||||
pingConfiguration->set_high_latency_threshold_ms(200);
|
||||
|
||||
|
||||
auto *headUnitInfo = serviceDiscoveryResponse.mutable_headunit_info();
|
||||
|
||||
serviceDiscoveryResponse.set_display_name("Crankshaft-NG");
|
||||
headUnitInfo->set_make("Crankshaft");
|
||||
headUnitInfo->set_model("Universal");
|
||||
headUnitInfo->set_year("2018");
|
||||
headUnitInfo->set_vehicle_id("2024110822150988");
|
||||
headUnitInfo->set_head_unit_make("f1x");
|
||||
headUnitInfo->set_head_unit_model("Crankshaft-NG Autoapp");
|
||||
headUnitInfo->set_head_unit_software_build("1");
|
||||
headUnitInfo->set_head_unit_software_version("1.0");
|
||||
|
||||
std::for_each(serviceList_.begin(), serviceList_.end(),
|
||||
std::bind(&IService::fillFeatures, std::placeholders::_1, std::ref(serviceDiscoveryResponse)));
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() { },
|
||||
std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
controlServiceChannel_->sendServiceDiscoveryResponse(serviceDiscoveryResponse, std::move(promise));
|
||||
controlServiceChannel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void AndroidAutoEntity::onAudioFocusRequest(
|
||||
const aap_protobuf::service::control::message::AudioFocusRequest &request) {
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] onAudioFocusRequest()";
|
||||
OPENAUTO_LOG(debug) << "[AndroidAutoEntity] AudioFocusRequestType received: "
|
||||
<< AudioFocusRequestType_Name(request.audio_focus_type());
|
||||
|
||||
/*
|
||||
* When the MD starts playing music for example, it sends a gain request. The HU replies:
|
||||
* STATE_GAIN - no restrictions
|
||||
* STATE_GAIN_MEDIA_ONLY when using a guidance channel
|
||||
* STATE_LOSS when vehicle is playing high priority sound after stopping native media (ie USB, RADIO)
|
||||
*
|
||||
* When HU starts playing music, we should send a STATE LOSS to stop MD music and guidance.
|
||||
*/
|
||||
|
||||
// If release, we should stop all playback
|
||||
// MD wants to play a sound, get a notifiation regarding GAIN
|
||||
// HU grants focus - to enable MD to send audio over both MEDIA and GUIDANCE channels.
|
||||
// MD can then play guidance over the MEDIA or GUIDANCE streams
|
||||
// HU should send STATE_LOSS to stop MD playing (ie if user starts radio player)
|
||||
aap_protobuf::service::control::message::AudioFocusStateType audioFocusStateType =
|
||||
request.audio_focus_type() ==
|
||||
aap_protobuf::service::control::message::AudioFocusRequestType::AUDIO_FOCUS_RELEASE
|
||||
? aap_protobuf::service::control::message::AudioFocusStateType::AUDIO_FOCUS_STATE_LOSS
|
||||
: aap_protobuf::service::control::message::AudioFocusStateType::AUDIO_FOCUS_STATE_GAIN;
|
||||
|
||||
OPENAUTO_LOG(debug) << "[AndroidAutoEntity] AudioFocusStateType determined: "
|
||||
<< AudioFocusStateType_Name(audioFocusStateType);
|
||||
|
||||
aap_protobuf::service::control::message::AudioFocusNotification response;
|
||||
response.set_focus_state(audioFocusStateType);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() { },
|
||||
[capture0 = this->shared_from_this()](auto && PH1) { capture0->onChannelError(std::forward<decltype(PH1)>(PH1)); });
|
||||
controlServiceChannel_->sendAudioFocusResponse(response, std::move(promise));
|
||||
controlServiceChannel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void AndroidAutoEntity::onByeByeRequest(
|
||||
const aap_protobuf::service::control::message::ByeByeRequest &request) {
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] onByeByeRequest()";
|
||||
OPENAUTO_LOG(debug) << "[AndroidAutoEntity] Reason received: " << request.reason();
|
||||
|
||||
aap_protobuf::service::control::message::ByeByeResponse response;
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then(std::bind(&AndroidAutoEntity::triggerQuit, this->shared_from_this()),
|
||||
std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
|
||||
controlServiceChannel_->sendShutdownResponse(response, std::move(promise));
|
||||
}
|
||||
|
||||
void AndroidAutoEntity::onByeByeResponse(
|
||||
const aap_protobuf::service::control::message::ByeByeResponse &response) {
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] onByeByeResponse()";
|
||||
this->triggerQuit();
|
||||
}
|
||||
|
||||
void AndroidAutoEntity::onNavigationFocusRequest(
|
||||
const aap_protobuf::service::control::message::NavFocusRequestNotification &request) {
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] onNavigationFocusRequest()";
|
||||
OPENAUTO_LOG(debug) << "[AndroidAutoEntity] NavFocusRequestNotification type received: " << NavFocusType_Name(request.focus_type());
|
||||
|
||||
/*
|
||||
* If the MD sends NAV_FOCUS_PROJECTED in the request, we should stop any local navigation on the HU and grant NAV_FOCUS_NATIVE in the response.
|
||||
* If the HU starts its own Nav, we should send NAV_FOCUS_NATIVE.
|
||||
*
|
||||
* For now, this is fine to be hardcoded as OpenAuto does not provide any local navigation, only that provided through Android Auto.
|
||||
*/
|
||||
aap_protobuf::service::control::message::NavFocusNotification response;
|
||||
response.set_focus_type(
|
||||
aap_protobuf::service::control::message::NavFocusType::NAV_FOCUS_PROJECTED);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {},
|
||||
std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
controlServiceChannel_->sendNavigationFocusResponse(response, std::move(promise));
|
||||
controlServiceChannel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void AndroidAutoEntity::onBatteryStatusNotification(const aap_protobuf::service::control::message::BatteryStatusNotification ¬ification) {
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] onBatteryStatusNotification()";
|
||||
controlServiceChannel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void AndroidAutoEntity::onPingRequest(const aap_protobuf::service::control::message::PingRequest& request) {
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] onPingRequest()";
|
||||
controlServiceChannel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void AndroidAutoEntity::onVoiceSessionRequest(
|
||||
const aap_protobuf::service::control::message::VoiceSessionNotification &request) {
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] onVoiceSessionRequest()";
|
||||
controlServiceChannel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void AndroidAutoEntity::onPingResponse(const aap_protobuf::service::control::message::PingResponse &response) {
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] onPingResponse()";
|
||||
OPENAUTO_LOG(debug) << "[AndroidAutoEntity] Timestamp: " << response.timestamp();
|
||||
pinger_->pong();
|
||||
controlServiceChannel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void AndroidAutoEntity::onChannelError(const aasdk::error::Error &e) {
|
||||
OPENAUTO_LOG(fatal) << "[AndroidAutoEntity] onChannelError(): " << e.what();
|
||||
this->triggerQuit();
|
||||
}
|
||||
|
||||
void AndroidAutoEntity::triggerQuit() {
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] triggerQuit()";
|
||||
if (eventHandler_ != nullptr) {
|
||||
eventHandler_->onAndroidAutoQuit();
|
||||
}
|
||||
}
|
||||
|
||||
void AndroidAutoEntity::schedulePing() {
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] schedulePing()";
|
||||
auto promise = IPinger::Promise::defer(strand_);
|
||||
promise->then([this, self = this->shared_from_this()]() {
|
||||
this->sendPing();
|
||||
this->schedulePing();
|
||||
},
|
||||
[this, self = this->shared_from_this()](auto error) {
|
||||
if (error != aasdk::error::ErrorCode::OPERATION_ABORTED &&
|
||||
error != aasdk::error::ErrorCode::OPERATION_IN_PROGRESS) {
|
||||
OPENAUTO_LOG(error) << "[AndroidAutoEntity] Ping timer exceeded.";
|
||||
this->triggerQuit();
|
||||
}
|
||||
});
|
||||
|
||||
pinger_->ping(std::move(promise));
|
||||
}
|
||||
|
||||
void AndroidAutoEntity::sendPing() {
|
||||
OPENAUTO_LOG(debug) << "[AndroidAutoEntity] sendPing()";
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {},
|
||||
std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
|
||||
aap_protobuf::service::control::message::PingRequest request;
|
||||
auto timestamp = std::chrono::duration_cast<std::chrono::microseconds>(
|
||||
std::chrono::high_resolution_clock::now().time_since_epoch());
|
||||
request.set_timestamp(timestamp.count());
|
||||
controlServiceChannel_->sendPingRequest(request, std::move(promise));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,53 +28,47 @@
|
||||
#include <f1x/openauto/autoapp/Service/AndroidAutoEntity.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/Pinger.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace service
|
||||
{
|
||||
namespace f1x {
|
||||
namespace openauto {
|
||||
namespace autoapp {
|
||||
namespace service {
|
||||
|
||||
AndroidAutoEntityFactory::AndroidAutoEntityFactory(boost::asio::io_service& ioService,
|
||||
configuration::IConfiguration::Pointer configuration,
|
||||
IServiceFactory& serviceFactory)
|
||||
: ioService_(ioService)
|
||||
, configuration_(std::move(configuration))
|
||||
, serviceFactory_(serviceFactory)
|
||||
{
|
||||
AndroidAutoEntityFactory::AndroidAutoEntityFactory(boost::asio::io_service &ioService,
|
||||
configuration::IConfiguration::Pointer configuration,
|
||||
IServiceFactory &serviceFactory)
|
||||
: ioService_(ioService), configuration_(std::move(configuration)), serviceFactory_(serviceFactory) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
IAndroidAutoEntity::Pointer AndroidAutoEntityFactory::create(aasdk::usb::IAOAPDevice::Pointer aoapDevice)
|
||||
{
|
||||
auto transport(std::make_shared<aasdk::transport::USBTransport>(ioService_, std::move(aoapDevice)));
|
||||
return create(std::move(transport));
|
||||
}
|
||||
IAndroidAutoEntity::Pointer AndroidAutoEntityFactory::create(aasdk::usb::IAOAPDevice::Pointer aoapDevice) {
|
||||
auto transport(std::make_shared<aasdk::transport::USBTransport>(ioService_, std::move(aoapDevice)));
|
||||
return create(std::move(transport));
|
||||
}
|
||||
|
||||
IAndroidAutoEntity::Pointer AndroidAutoEntityFactory::create(aasdk::tcp::ITCPEndpoint::Pointer tcpEndpoint)
|
||||
{
|
||||
auto transport(std::make_shared<aasdk::transport::TCPTransport>(ioService_, std::move(tcpEndpoint)));
|
||||
return create(std::move(transport));
|
||||
}
|
||||
IAndroidAutoEntity::Pointer AndroidAutoEntityFactory::create(aasdk::tcp::ITCPEndpoint::Pointer tcpEndpoint) {
|
||||
auto transport(std::make_shared<aasdk::transport::TCPTransport>(ioService_, std::move(tcpEndpoint)));
|
||||
return create(std::move(transport));
|
||||
}
|
||||
|
||||
IAndroidAutoEntity::Pointer AndroidAutoEntityFactory::create(aasdk::transport::ITransport::Pointer transport)
|
||||
{
|
||||
auto sslWrapper(std::make_shared<aasdk::transport::SSLWrapper>());
|
||||
auto cryptor(std::make_shared<aasdk::messenger::Cryptor>(std::move(sslWrapper)));
|
||||
cryptor->init();
|
||||
IAndroidAutoEntity::Pointer AndroidAutoEntityFactory::create(aasdk::transport::ITransport::Pointer transport) {
|
||||
auto sslWrapper(std::make_shared<aasdk::transport::SSLWrapper>());
|
||||
auto cryptor(std::make_shared<aasdk::messenger::Cryptor>(std::move(sslWrapper)));
|
||||
cryptor->init();
|
||||
|
||||
auto messenger(std::make_shared<aasdk::messenger::Messenger>(ioService_,
|
||||
std::make_shared<aasdk::messenger::MessageInStream>(ioService_, transport, cryptor),
|
||||
std::make_shared<aasdk::messenger::MessageOutStream>(ioService_, transport, cryptor)));
|
||||
auto messenger(std::make_shared<aasdk::messenger::Messenger>(ioService_,
|
||||
std::make_shared<aasdk::messenger::MessageInStream>(
|
||||
ioService_, transport, cryptor),
|
||||
std::make_shared<aasdk::messenger::MessageOutStream>(
|
||||
ioService_, transport, cryptor)));
|
||||
|
||||
auto serviceList = serviceFactory_.create(messenger);
|
||||
auto pinger(std::make_shared<Pinger>(ioService_, 5000));
|
||||
return std::make_shared<AndroidAutoEntity>(ioService_, std::move(cryptor), std::move(transport), std::move(messenger), configuration_, std::move(serviceList), std::move(pinger));
|
||||
}
|
||||
auto serviceList = serviceFactory_.create(messenger);
|
||||
auto pinger(std::make_shared<Pinger>(ioService_, 5000));
|
||||
return std::make_shared<AndroidAutoEntity>(ioService_, std::move(cryptor), std::move(transport),
|
||||
std::move(messenger), configuration_, std::move(serviceList),
|
||||
std::move(pinger));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,215 +0,0 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <time.h>
|
||||
#include <f1x/openauto/Common/Log.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/AudioInputService.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace service
|
||||
{
|
||||
|
||||
AudioInputService::AudioInputService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IAudioInput::Pointer audioInput)
|
||||
: strand_(ioService)
|
||||
, channel_(std::make_shared<aasdk::channel::av::AVInputServiceChannel>(strand_, std::move(messenger)))
|
||||
, audioInput_(std::move(audioInput))
|
||||
, session_(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AudioInputService::start()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[AudioInputService] start.";
|
||||
channel_->receive(this->shared_from_this());
|
||||
});
|
||||
}
|
||||
|
||||
void AudioInputService::stop()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[AudioInputService] stop.";
|
||||
audioInput_->stop();
|
||||
});
|
||||
}
|
||||
|
||||
void AudioInputService::pause()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[AudioInputService] pause.";
|
||||
});
|
||||
}
|
||||
|
||||
void AudioInputService::resume()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[AudioInputService] resume.";
|
||||
});
|
||||
}
|
||||
|
||||
void AudioInputService::fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[AudioInputService] fill features.";
|
||||
|
||||
auto* channelDescriptor = response.add_channels();
|
||||
channelDescriptor->set_channel_id(static_cast<uint32_t>(channel_->getId()));
|
||||
|
||||
auto* avInputChannel = channelDescriptor->mutable_av_input_channel();
|
||||
avInputChannel->set_stream_type(aasdk::proto::enums::AVStreamType::AUDIO);
|
||||
|
||||
auto audioConfig = avInputChannel->mutable_audio_config();
|
||||
audioConfig->set_sample_rate(audioInput_->getSampleRate());
|
||||
audioConfig->set_bit_depth(audioInput_->getSampleSize());
|
||||
audioConfig->set_channel_count(audioInput_->getChannelCount());
|
||||
}
|
||||
|
||||
void AudioInputService::onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[AudioInputService] open request, priority: " << request.priority();
|
||||
const aasdk::proto::enums::Status::Enum status = audioInput_->open() ? aasdk::proto::enums::Status::OK : aasdk::proto::enums::Status::FAIL;
|
||||
OPENAUTO_LOG(info) << "[AudioInputService] open status: " << status;
|
||||
|
||||
aasdk::proto::messages::ChannelOpenResponse response;
|
||||
response.set_status(status);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&AudioInputService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
channel_->sendChannelOpenResponse(response, std::move(promise));
|
||||
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void AudioInputService::onAVChannelSetupRequest(const aasdk::proto::messages::AVChannelSetupRequest& request)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[AudioInputService] setup request, config index: " << request.config_index();
|
||||
const aasdk::proto::enums::AVChannelSetupStatus::Enum status = aasdk::proto::enums::AVChannelSetupStatus::OK;
|
||||
OPENAUTO_LOG(info) << "[AudioInputService] setup status: " << status;
|
||||
|
||||
|
||||
aasdk::proto::messages::AVChannelSetupResponse response;
|
||||
response.set_media_status(status);
|
||||
response.set_max_unacked(1);
|
||||
response.add_configs(0);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&AudioInputService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
channel_->sendAVChannelSetupResponse(response, std::move(promise));
|
||||
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void AudioInputService::onAVInputOpenRequest(const aasdk::proto::messages::AVInputOpenRequest& request)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[AudioInputService] input open request, open: " << request.open()
|
||||
<< ", anc: " << request.anc()
|
||||
<< ", ec: " << request.ec()
|
||||
<< ", max unacked: " << request.max_unacked();
|
||||
|
||||
if(request.open())
|
||||
{
|
||||
auto startPromise = projection::IAudioInput::StartPromise::defer(strand_);
|
||||
startPromise->then(std::bind(&AudioInputService::onAudioInputOpenSucceed, this->shared_from_this()),
|
||||
[this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(error) << "[AudioInputService] audio input open failed.";
|
||||
|
||||
aasdk::proto::messages::AVInputOpenResponse response;
|
||||
response.set_session(session_);
|
||||
response.set_value(1);
|
||||
|
||||
auto sendPromise = aasdk::channel::SendPromise::defer(strand_);
|
||||
sendPromise->then([]() {}, std::bind(&AudioInputService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
channel_->sendAVInputOpenResponse(response, std::move(sendPromise));
|
||||
});
|
||||
|
||||
audioInput_->start(std::move(startPromise));
|
||||
}
|
||||
else
|
||||
{
|
||||
audioInput_->stop();
|
||||
|
||||
aasdk::proto::messages::AVInputOpenResponse response;
|
||||
response.set_session(session_);
|
||||
response.set_value(0);
|
||||
|
||||
auto sendPromise = aasdk::channel::SendPromise::defer(strand_);
|
||||
sendPromise->then([]() {}, std::bind(&AudioInputService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
channel_->sendAVInputOpenResponse(response, std::move(sendPromise));
|
||||
}
|
||||
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void AudioInputService::onAVMediaAckIndication(const aasdk::proto::messages::AVMediaAckIndication&)
|
||||
{
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void AudioInputService::onChannelError(const aasdk::error::Error& e)
|
||||
{
|
||||
OPENAUTO_LOG(error) << "[AudioInputService] channel error: " << e.what();
|
||||
}
|
||||
|
||||
void AudioInputService::onAudioInputOpenSucceed()
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[AudioInputService] audio input open succeed.";
|
||||
|
||||
aasdk::proto::messages::AVInputOpenResponse response;
|
||||
response.set_session(session_);
|
||||
response.set_value(0);
|
||||
|
||||
auto sendPromise = aasdk::channel::SendPromise::defer(strand_);
|
||||
sendPromise->then([]() {}, std::bind(&AudioInputService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
channel_->sendAVInputOpenResponse(response, std::move(sendPromise));
|
||||
|
||||
this->readAudioInput();
|
||||
}
|
||||
|
||||
void AudioInputService::onAudioInputDataReady(aasdk::common::Data data)
|
||||
{
|
||||
auto sendPromise = aasdk::channel::SendPromise::defer(strand_);
|
||||
sendPromise->then(std::bind(&AudioInputService::readAudioInput, this->shared_from_this()),
|
||||
std::bind(&AudioInputService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
|
||||
auto timestamp = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now().time_since_epoch());
|
||||
channel_->sendAVMediaWithTimestampIndication(timestamp.count(), std::move(data), std::move(sendPromise));
|
||||
}
|
||||
|
||||
void AudioInputService::readAudioInput()
|
||||
{
|
||||
if(audioInput_->isActive())
|
||||
{
|
||||
auto readPromise = projection::IAudioInput::ReadPromise::defer(strand_);
|
||||
readPromise->then(std::bind(&AudioInputService::onAudioInputDataReady, this->shared_from_this(), std::placeholders::_1),
|
||||
[this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[AudioInputService] audio input read rejected.";
|
||||
});
|
||||
|
||||
audioInput_->read(std::move(readPromise));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,196 +0,0 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <f1x/openauto/Common/Log.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/AudioService.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace service
|
||||
{
|
||||
|
||||
AudioService::AudioService(boost::asio::io_service& ioService, aasdk::channel::av::IAudioServiceChannel::Pointer channel, projection::IAudioOutput::Pointer audioOutput)
|
||||
: strand_(ioService)
|
||||
, channel_(std::move(channel))
|
||||
, audioOutput_(std::move(audioOutput))
|
||||
, session_(-1)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AudioService::start()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[AudioService] start, channel: " << aasdk::messenger::channelIdToString(channel_->getId());
|
||||
channel_->receive(this->shared_from_this());
|
||||
});
|
||||
}
|
||||
|
||||
void AudioService::stop()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[AudioService] stop, channel: " << aasdk::messenger::channelIdToString(channel_->getId());
|
||||
audioOutput_->stop();
|
||||
});
|
||||
}
|
||||
|
||||
void AudioService::pause()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[AudioService] pause.";
|
||||
});
|
||||
}
|
||||
|
||||
void AudioService::resume()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[AudioService] resume.";
|
||||
});
|
||||
}
|
||||
|
||||
void AudioService::fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[AudioService] fill features, channel: " << aasdk::messenger::channelIdToString(channel_->getId());
|
||||
|
||||
auto* channelDescriptor = response.add_channels();
|
||||
channelDescriptor->set_channel_id(static_cast<uint32_t>(channel_->getId()));
|
||||
|
||||
auto* audioChannel = channelDescriptor->mutable_av_channel();
|
||||
audioChannel->set_stream_type(aasdk::proto::enums::AVStreamType::AUDIO);
|
||||
|
||||
switch(channel_->getId())
|
||||
{
|
||||
case aasdk::messenger::ChannelId::SYSTEM_AUDIO:
|
||||
audioChannel->set_audio_type(aasdk::proto::enums::AudioType::SYSTEM);
|
||||
break;
|
||||
|
||||
case aasdk::messenger::ChannelId::MEDIA_AUDIO:
|
||||
audioChannel->set_audio_type(aasdk::proto::enums::AudioType::MEDIA);
|
||||
break;
|
||||
|
||||
case aasdk::messenger::ChannelId::SPEECH_AUDIO:
|
||||
audioChannel->set_audio_type(aasdk::proto::enums::AudioType::SPEECH);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
audioChannel->set_available_while_in_call(true);
|
||||
|
||||
auto* audioConfig = audioChannel->add_audio_configs();
|
||||
audioConfig->set_sample_rate(audioOutput_->getSampleRate());
|
||||
audioConfig->set_bit_depth(audioOutput_->getSampleSize());
|
||||
audioConfig->set_channel_count(audioOutput_->getChannelCount());
|
||||
}
|
||||
|
||||
void AudioService::onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[AudioService] open request"
|
||||
<< ", channel: " << aasdk::messenger::channelIdToString(channel_->getId())
|
||||
<< ", priority: " << request.priority();
|
||||
|
||||
OPENAUTO_LOG(debug) << "[AudioService] channel: " << aasdk::messenger::channelIdToString(channel_->getId())
|
||||
<< " audio output sample rate: " << audioOutput_->getSampleRate()
|
||||
<< ", sample size: " << audioOutput_->getSampleSize()
|
||||
<< ", channel count: " << audioOutput_->getChannelCount();
|
||||
|
||||
const aasdk::proto::enums::Status::Enum status = audioOutput_->open() ? aasdk::proto::enums::Status::OK : aasdk::proto::enums::Status::FAIL;
|
||||
OPENAUTO_LOG(info) << "[AudioService] open status: " << status
|
||||
<< ", channel: " << aasdk::messenger::channelIdToString(channel_->getId());
|
||||
|
||||
aasdk::proto::messages::ChannelOpenResponse response;
|
||||
response.set_status(status);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&AudioService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
channel_->sendChannelOpenResponse(response, std::move(promise));
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void AudioService::onAVChannelSetupRequest(const aasdk::proto::messages::AVChannelSetupRequest& request)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[AudioService] setup request"
|
||||
<< ", channel: " << aasdk::messenger::channelIdToString(channel_->getId())
|
||||
<< ", config index: " << request.config_index();
|
||||
const aasdk::proto::enums::AVChannelSetupStatus::Enum status = aasdk::proto::enums::AVChannelSetupStatus::OK;
|
||||
OPENAUTO_LOG(info) << "[AudioService] setup status: " << status
|
||||
<< ", channel: " << aasdk::messenger::channelIdToString(channel_->getId());
|
||||
|
||||
aasdk::proto::messages::AVChannelSetupResponse response;
|
||||
response.set_media_status(status);
|
||||
response.set_max_unacked(1);
|
||||
response.add_configs(0);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&AudioService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
channel_->sendAVChannelSetupResponse(response, std::move(promise));
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void AudioService::onAVChannelStartIndication(const aasdk::proto::messages::AVChannelStartIndication& indication)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[AudioService] start indication"
|
||||
<< ", channel: " << aasdk::messenger::channelIdToString(channel_->getId())
|
||||
<< ", session: " << indication.session();
|
||||
session_ = indication.session();
|
||||
audioOutput_->start();
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void AudioService::onAVChannelStopIndication(const aasdk::proto::messages::AVChannelStopIndication& indication)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[AudioService] stop indication"
|
||||
<< ", channel: " << aasdk::messenger::channelIdToString(channel_->getId())
|
||||
<< ", session: " << session_;
|
||||
session_ = -1;
|
||||
audioOutput_->suspend();
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void AudioService::onAVMediaWithTimestampIndication(aasdk::messenger::Timestamp::ValueType timestamp, const aasdk::common::DataConstBuffer& buffer)
|
||||
{
|
||||
audioOutput_->write(timestamp, buffer);
|
||||
aasdk::proto::messages::AVMediaAckIndication indication;
|
||||
indication.set_session(session_);
|
||||
indication.set_value(1);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&AudioService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
channel_->sendAVMediaAckIndication(indication, std::move(promise));
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void AudioService::onAVMediaIndication(const aasdk::common::DataConstBuffer& buffer)
|
||||
{
|
||||
this->onAVMediaWithTimestampIndication(0, buffer);
|
||||
}
|
||||
|
||||
void AudioService::onChannelError(const aasdk::error::Error& e)
|
||||
{
|
||||
OPENAUTO_LOG(error) << "[AudioService] channel error: " << e.what()
|
||||
<< ", channel: " << aasdk::messenger::channelIdToString(channel_->getId());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
164
src/autoapp/Service/Bluetooth/BluetoothService.cpp
Normal file
164
src/autoapp/Service/Bluetooth/BluetoothService.cpp
Normal file
@ -0,0 +1,164 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <f1x/openauto/Common/Log.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/Bluetooth/BluetoothService.hpp>
|
||||
|
||||
namespace f1x::openauto::autoapp::service::bluetooth {
|
||||
|
||||
BluetoothService::BluetoothService(boost::asio::io_service &ioService,
|
||||
aasdk::messenger::IMessenger::Pointer messenger,
|
||||
projection::IBluetoothDevice::Pointer bluetoothDevice)
|
||||
: strand_(ioService),
|
||||
channel_(std::make_shared<aasdk::channel::bluetooth::BluetoothService>(strand_, std::move(messenger))),
|
||||
bluetoothDevice_(std::move(bluetoothDevice)) {
|
||||
|
||||
}
|
||||
|
||||
void BluetoothService::start() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[BluetoothService] start()";
|
||||
channel_->receive(this->shared_from_this());
|
||||
});
|
||||
}
|
||||
|
||||
void BluetoothService::stop() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[BluetoothService] stop()";
|
||||
bluetoothDevice_->stop();
|
||||
});
|
||||
}
|
||||
|
||||
void BluetoothService::pause() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[BluetoothService] pause()";
|
||||
});
|
||||
}
|
||||
|
||||
void BluetoothService::resume() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[BluetoothService] resume()";
|
||||
});
|
||||
}
|
||||
|
||||
void BluetoothService::fillFeatures(
|
||||
aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) {
|
||||
OPENAUTO_LOG(info) << "[BluetoothService] fillFeatures()";
|
||||
|
||||
auto *service = response.add_channels();
|
||||
service->set_id(static_cast<uint32_t>(channel_->getId()));
|
||||
|
||||
auto bluetooth = service->mutable_bluetooth_service();
|
||||
|
||||
if (bluetoothDevice_->isAvailable()) {
|
||||
OPENAUTO_LOG(info) << "[BluetoothService] Local Address: " << bluetoothDevice_->getAdapterAddress();
|
||||
|
||||
// TODO: Also need to re-establish Bluetooth
|
||||
// If the HU wants the MD to skip the Bluetooth Pairing and Connection process, the HU can declare its address as SKIP_THIS_BLUETOOTH
|
||||
bluetooth->set_car_address(bluetoothDevice_->getAdapterAddress());
|
||||
|
||||
// AAP supports bth PIN and Numeric Comparison as pairing methods.
|
||||
bluetooth->add_supported_pairing_methods(
|
||||
aap_protobuf::service::bluetooth::message::BluetoothPairingMethod::BLUETOOTH_PAIRING_PIN);
|
||||
bluetooth->add_supported_pairing_methods(
|
||||
aap_protobuf::service::bluetooth::message::BluetoothPairingMethod::BLUETOOTH_PAIRING_NUMERIC_COMPARISON);
|
||||
} else {
|
||||
OPENAUTO_LOG(info) << "[BluetoothService] Bluetooth Not Available ";
|
||||
bluetooth->set_car_address("");
|
||||
bluetooth->add_supported_pairing_methods(aap_protobuf::service::bluetooth::message::BluetoothPairingMethod::BLUETOOTH_PAIRING_UNAVAILABLE);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothService::onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) {
|
||||
OPENAUTO_LOG(info) << "[BluetoothService] onChannelOpenRequest()";
|
||||
OPENAUTO_LOG(debug) << "[BluetoothService] Channel Id: " << request.service_id() << ", Priority: "
|
||||
<< request.priority();
|
||||
|
||||
aap_protobuf::service::control::message::ChannelOpenResponse response;
|
||||
const aap_protobuf::shared::MessageStatus status = aap_protobuf::shared::MessageStatus::STATUS_SUCCESS;
|
||||
response.set_status(status);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&BluetoothService::onChannelError, this->shared_from_this(),
|
||||
std::placeholders::_1));
|
||||
channel_->sendChannelOpenResponse(response, std::move(promise));
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void BluetoothService::onBluetoothPairingRequest(
|
||||
const aap_protobuf::service::bluetooth::message::BluetoothPairingRequest &request) {
|
||||
OPENAUTO_LOG(info) << "[BluetoothService] onBluetoothPairingRequest()";
|
||||
OPENAUTO_LOG(info) << "[BluetoothService] Phone Address: " << request.phone_address();
|
||||
|
||||
aap_protobuf::service::bluetooth::message::BluetoothPairingResponse response;
|
||||
|
||||
const auto isPaired = bluetoothDevice_->isPaired(request.phone_address());
|
||||
if (isPaired) {
|
||||
OPENAUTO_LOG(info) << "[BluetoothService] Phone is Already Paired";
|
||||
} else {
|
||||
OPENAUTO_LOG(info) << "[BluetoothService] Phone is Not Paired";
|
||||
}
|
||||
|
||||
/*
|
||||
* The HU must always sent a STATUS_SUCCESS response,
|
||||
* or STATUS_BLUETOOTH_PAIRING_DELAYED if:
|
||||
* there's a delay in allowing bluetooth
|
||||
* the HU is already engaged in a bluetooth call
|
||||
*/
|
||||
response.set_status(aap_protobuf::shared::MessageStatus::STATUS_SUCCESS);
|
||||
response.set_already_paired(isPaired);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then(std::bind(&BluetoothService::sendBluetoothAuthenticationData, this->shared_from_this()),
|
||||
std::bind(&BluetoothService::onChannelError, this->shared_from_this(),
|
||||
std::placeholders::_1));
|
||||
channel_->sendBluetoothPairingResponse(response, std::move(promise));
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void BluetoothService::sendBluetoothAuthenticationData() {
|
||||
OPENAUTO_LOG(info) << "[BluetoothService] sendBluetoothAuthenticationData()";
|
||||
|
||||
aap_protobuf::service::bluetooth::message::BluetoothAuthenticationData data;
|
||||
// TODO: Bluetooth Authentication Data
|
||||
data.set_auth_data("123456");
|
||||
data.set_pairing_method(aap_protobuf::service::bluetooth::message::BluetoothPairingMethod::BLUETOOTH_PAIRING_PIN);
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&BluetoothService::onChannelError, this->shared_from_this(),
|
||||
std::placeholders::_1));
|
||||
channel_->sendBluetoothAuthenticationData(data, std::move(promise));
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void BluetoothService::onBluetoothAuthenticationResult(
|
||||
const aap_protobuf::service::bluetooth::message::BluetoothAuthenticationResult &request) {
|
||||
OPENAUTO_LOG(info) << "[BluetoothService] onBluetoothAuthenticationResult()";
|
||||
OPENAUTO_LOG(info) << "[BluetoothService] AuthData " << request.status();
|
||||
aap_protobuf::service::bluetooth::message::BluetoothPairingResponse response;
|
||||
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void BluetoothService::onChannelError(const aasdk::error::Error &e) {
|
||||
OPENAUTO_LOG(error) << "[BluetoothService] onChannelError(): " << e.what();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,127 +0,0 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <f1x/openauto/Common/Log.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/BluetoothService.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace service
|
||||
{
|
||||
|
||||
BluetoothService::BluetoothService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IBluetoothDevice::Pointer bluetoothDevice)
|
||||
: strand_(ioService)
|
||||
, channel_(std::make_shared<aasdk::channel::bluetooth::BluetoothServiceChannel>(strand_, std::move(messenger)))
|
||||
, bluetoothDevice_(std::move(bluetoothDevice))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void BluetoothService::start()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[BluetoothService] start.";
|
||||
channel_->receive(this->shared_from_this());
|
||||
});
|
||||
}
|
||||
|
||||
void BluetoothService::stop()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[BluetoothService] stop.";
|
||||
bluetoothDevice_->stop();
|
||||
});
|
||||
}
|
||||
|
||||
void BluetoothService::pause()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[BluetoothService] pause.";
|
||||
});
|
||||
}
|
||||
|
||||
void BluetoothService::resume()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[BluetoothService] resume.";
|
||||
});
|
||||
}
|
||||
|
||||
void BluetoothService::fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[BluetoothService] fill features";
|
||||
|
||||
if(bluetoothDevice_->isAvailable())
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[BluetoothService] sending local adapter adress: " << bluetoothDevice_->getLocalAddress();
|
||||
|
||||
auto* channelDescriptor = response.add_channels();
|
||||
channelDescriptor->set_channel_id(static_cast<uint32_t>(channel_->getId()));
|
||||
auto bluetoothChannel = channelDescriptor->mutable_bluetooth_channel();
|
||||
bluetoothChannel->set_adapter_address(bluetoothDevice_->getLocalAddress());
|
||||
bluetoothChannel->add_supported_pairing_methods(aasdk::proto::enums::BluetoothPairingMethod_Enum_HFP);
|
||||
bluetoothChannel->add_supported_pairing_methods(aasdk::proto::enums::BluetoothPairingMethod_Enum_A2DP);
|
||||
}
|
||||
}
|
||||
|
||||
void BluetoothService::onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[BluetoothService] open request, priority: " << request.priority();
|
||||
const aasdk::proto::enums::Status::Enum status = aasdk::proto::enums::Status::OK;
|
||||
OPENAUTO_LOG(info) << "[BluetoothService] open status: " << status;
|
||||
|
||||
aasdk::proto::messages::ChannelOpenResponse response;
|
||||
response.set_status(status);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&BluetoothService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
channel_->sendChannelOpenResponse(response, std::move(promise));
|
||||
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void BluetoothService::onBluetoothPairingRequest(const aasdk::proto::messages::BluetoothPairingRequest& request)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[BluetoothService] pairing request, address: " << request.phone_address();
|
||||
|
||||
aasdk::proto::messages::BluetoothPairingResponse response;
|
||||
|
||||
const auto isPaired = bluetoothDevice_->isPaired(request.phone_address());
|
||||
response.set_already_paired(isPaired);
|
||||
response.set_status(isPaired ? aasdk::proto::enums::BluetoothPairingStatus::OK : aasdk::proto::enums::BluetoothPairingStatus::FAIL);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&BluetoothService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
channel_->sendBluetoothPairingResponse(response, std::move(promise));
|
||||
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void BluetoothService::onChannelError(const aasdk::error::Error& e)
|
||||
{
|
||||
OPENAUTO_LOG(error) << "[BluetoothService] channel error: " << e.what();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <f1x/openauto/Common/Log.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/GenericNotification/GenericNotificationService.hpp>
|
||||
#include <fstream>
|
||||
#include <QString>
|
||||
|
||||
namespace f1x::openauto::autoapp::service::genericnotification {
|
||||
|
||||
GenericNotificationService::GenericNotificationService(boost::asio::io_service &ioService,
|
||||
aasdk::messenger::IMessenger::Pointer messenger)
|
||||
: strand_(ioService),
|
||||
timer_(ioService),
|
||||
channel_(std::make_shared<aasdk::channel::genericnotification::GenericNotificationService>(strand_, std::move(
|
||||
messenger))) {
|
||||
|
||||
}
|
||||
|
||||
void GenericNotificationService::start() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[GenericNotificationService] start()";
|
||||
});
|
||||
}
|
||||
|
||||
void GenericNotificationService::stop() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[GenericNotificationService] stop()";
|
||||
});
|
||||
}
|
||||
|
||||
void GenericNotificationService::pause() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[GenericNotificationService] pause()";
|
||||
});
|
||||
}
|
||||
|
||||
void GenericNotificationService::resume() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[GenericNotificationService] resume()";
|
||||
});
|
||||
}
|
||||
|
||||
void GenericNotificationService::fillFeatures(
|
||||
aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) {
|
||||
OPENAUTO_LOG(info) << "[GenericNotificationService] fillFeatures()";
|
||||
|
||||
auto *service = response.add_channels();
|
||||
service->set_id(static_cast<uint32_t>(channel_->getId()));
|
||||
|
||||
auto *genericNotification = service->mutable_wifi_projection_service();
|
||||
}
|
||||
|
||||
void GenericNotificationService::onChannelOpenRequest(
|
||||
const aap_protobuf::service::control::message::ChannelOpenRequest &request) {
|
||||
OPENAUTO_LOG(info) << "[GenericNotificationService] onChannelOpenRequest()";
|
||||
OPENAUTO_LOG(debug) << "[GenericNotificationService] Channel Id: " << request.service_id() << ", Priority: "
|
||||
<< request.priority();
|
||||
|
||||
aap_protobuf::service::control::message::ChannelOpenResponse response;
|
||||
const aap_protobuf::shared::MessageStatus status = aap_protobuf::shared::MessageStatus::STATUS_SUCCESS;
|
||||
response.set_status(status);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&GenericNotificationService::onChannelError, this->shared_from_this(),
|
||||
std::placeholders::_1));
|
||||
channel_->sendChannelOpenResponse(response, std::move(promise));
|
||||
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void GenericNotificationService::onChannelError(const aasdk::error::Error &e) {
|
||||
OPENAUTO_LOG(error) << "[GenericNotificationService] onChannelError(): " << e.what();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,205 +0,0 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <aasdk_proto/InputEventIndicationMessage.pb.h>
|
||||
#include <f1x/openauto/Common/Log.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/InputService.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace service
|
||||
{
|
||||
|
||||
InputService::InputService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IInputDevice::Pointer inputDevice)
|
||||
: strand_(ioService)
|
||||
, channel_(std::make_shared<aasdk::channel::input::InputServiceChannel>(strand_, std::move(messenger)))
|
||||
, inputDevice_(std::move(inputDevice))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void InputService::start()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[InputService] start.";
|
||||
channel_->receive(this->shared_from_this());
|
||||
});
|
||||
}
|
||||
|
||||
void InputService::stop()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[InputService] stop.";
|
||||
inputDevice_->stop();
|
||||
});
|
||||
}
|
||||
|
||||
void InputService::pause()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[InputService] pause.";
|
||||
});
|
||||
}
|
||||
|
||||
void InputService::resume()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[InputService] resume.";
|
||||
});
|
||||
}
|
||||
|
||||
void InputService::fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[InputService] fill features.";
|
||||
|
||||
auto* channelDescriptor = response.add_channels();
|
||||
channelDescriptor->set_channel_id(static_cast<uint32_t>(channel_->getId()));
|
||||
|
||||
auto* inputChannel = channelDescriptor->mutable_input_channel();
|
||||
|
||||
const auto& supportedButtonCodes = inputDevice_->getSupportedButtonCodes();
|
||||
|
||||
for(const auto& buttonCode : supportedButtonCodes)
|
||||
{
|
||||
inputChannel->add_supported_keycodes(buttonCode);
|
||||
}
|
||||
|
||||
if(inputDevice_->hasTouchscreen())
|
||||
{
|
||||
const auto& touchscreenSurface = inputDevice_->getTouchscreenGeometry();
|
||||
auto touchscreenConfig = inputChannel->mutable_touch_screen_config();
|
||||
|
||||
touchscreenConfig->set_width(touchscreenSurface.width());
|
||||
touchscreenConfig->set_height(touchscreenSurface.height());
|
||||
}
|
||||
}
|
||||
|
||||
void InputService::onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[InputService] open request, priority: " << request.priority();
|
||||
const aasdk::proto::enums::Status::Enum status = aasdk::proto::enums::Status::OK;
|
||||
OPENAUTO_LOG(info) << "[InputService] open status: " << status;
|
||||
|
||||
aasdk::proto::messages::ChannelOpenResponse response;
|
||||
response.set_status(status);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&InputService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
channel_->sendChannelOpenResponse(response, std::move(promise));
|
||||
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void InputService::onBindingRequest(const aasdk::proto::messages::BindingRequest& request)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[InputService] binding request, scan codes count: " << request.scan_codes_size();
|
||||
|
||||
aasdk::proto::enums::Status::Enum status = aasdk::proto::enums::Status::OK;
|
||||
const auto& supportedButtonCodes = inputDevice_->getSupportedButtonCodes();
|
||||
|
||||
for(int i = 0; i < request.scan_codes_size(); ++i)
|
||||
{
|
||||
if(std::find(supportedButtonCodes.begin(), supportedButtonCodes.end(), request.scan_codes(i)) == supportedButtonCodes.end())
|
||||
{
|
||||
OPENAUTO_LOG(error) << "[InputService] binding request, scan code: " << request.scan_codes(i)
|
||||
<< " is not supported.";
|
||||
|
||||
status = aasdk::proto::enums::Status::FAIL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
aasdk::proto::messages::BindingResponse response;
|
||||
response.set_status(status);
|
||||
|
||||
if(status == aasdk::proto::enums::Status::OK)
|
||||
{
|
||||
inputDevice_->start(*this);
|
||||
}
|
||||
|
||||
OPENAUTO_LOG(info) << "[InputService] binding request, status: " << status;
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&InputService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
channel_->sendBindingResponse(response, std::move(promise));
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void InputService::onChannelError(const aasdk::error::Error& e)
|
||||
{
|
||||
OPENAUTO_LOG(error) << "[SensorService] channel error: " << e.what();
|
||||
}
|
||||
|
||||
void InputService::onButtonEvent(const projection::ButtonEvent& event)
|
||||
{
|
||||
auto timestamp = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now().time_since_epoch());
|
||||
|
||||
strand_.dispatch([this, self = this->shared_from_this(), event = std::move(event), timestamp = std::move(timestamp)]() {
|
||||
aasdk::proto::messages::InputEventIndication inputEventIndication;
|
||||
inputEventIndication.set_timestamp(timestamp.count());
|
||||
|
||||
if(event.code == aasdk::proto::enums::ButtonCode::SCROLL_WHEEL)
|
||||
{
|
||||
auto relativeEvent = inputEventIndication.mutable_relative_input_event()->add_relative_input_events();
|
||||
relativeEvent->set_delta(event.wheelDirection == projection::WheelDirection::LEFT ? -1 : 1);
|
||||
relativeEvent->set_scan_code(event.code);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto buttonEvent = inputEventIndication.mutable_button_event()->add_button_events();
|
||||
buttonEvent->set_meta(0);
|
||||
buttonEvent->set_is_pressed(event.type == projection::ButtonEventType::PRESS);
|
||||
buttonEvent->set_long_press(false);
|
||||
buttonEvent->set_scan_code(event.code);
|
||||
}
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&InputService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
channel_->sendInputEventIndication(inputEventIndication, std::move(promise));
|
||||
});
|
||||
}
|
||||
|
||||
void InputService::onTouchEvent(const projection::TouchEvent& event)
|
||||
{
|
||||
auto timestamp = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now().time_since_epoch());
|
||||
|
||||
strand_.dispatch([this, self = this->shared_from_this(), event = std::move(event), timestamp = std::move(timestamp)]() {
|
||||
aasdk::proto::messages::InputEventIndication inputEventIndication;
|
||||
inputEventIndication.set_timestamp(timestamp.count());
|
||||
|
||||
auto touchEvent = inputEventIndication.mutable_touch_event();
|
||||
touchEvent->set_touch_action(event.type);
|
||||
auto touchLocation = touchEvent->add_touch_location();
|
||||
touchLocation->set_x(event.x);
|
||||
touchLocation->set_y(event.y);
|
||||
touchLocation->set_pointer_id(0);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&InputService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
channel_->sendInputEventIndication(inputEventIndication, std::move(promise));
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
194
src/autoapp/Service/InputSource/InputSourceService.cpp
Normal file
194
src/autoapp/Service/InputSource/InputSourceService.cpp
Normal file
@ -0,0 +1,194 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <f1x/openauto/Common/Log.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/InputSource/InputSourceService.hpp>
|
||||
|
||||
namespace f1x {
|
||||
namespace openauto {
|
||||
namespace autoapp {
|
||||
namespace service {
|
||||
namespace inputsource {
|
||||
InputSourceService::InputSourceService(boost::asio::io_service &ioService,
|
||||
aasdk::messenger::IMessenger::Pointer messenger,
|
||||
projection::IInputDevice::Pointer inputDevice)
|
||||
: strand_(ioService),
|
||||
channel_(std::make_shared<aasdk::channel::inputsource::InputSourceService>(strand_, std::move(messenger))),
|
||||
inputDevice_(std::move(inputDevice)) {
|
||||
|
||||
}
|
||||
|
||||
void InputSourceService::start() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[InputSourceService] start()";
|
||||
channel_->receive(this->shared_from_this());
|
||||
});
|
||||
}
|
||||
|
||||
void InputSourceService::stop() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[InputSourceService] stop()";
|
||||
inputDevice_->stop();
|
||||
});
|
||||
}
|
||||
|
||||
void InputSourceService::pause() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[InputSourceService] pause()";
|
||||
});
|
||||
}
|
||||
|
||||
void InputSourceService::resume() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[InputSourceService] resume()";
|
||||
});
|
||||
}
|
||||
|
||||
void InputSourceService::fillFeatures(
|
||||
aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) {
|
||||
OPENAUTO_LOG(info) << "[InputSourceService] fillFeatures()";
|
||||
|
||||
auto *service = response.add_channels();
|
||||
service->set_id(static_cast<uint32_t>(channel_->getId()));
|
||||
|
||||
auto *inputChannel = service->mutable_input_source_service();
|
||||
|
||||
const auto &supportedButtonCodes = inputDevice_->getSupportedButtonCodes();
|
||||
|
||||
for (const auto &buttonCode: supportedButtonCodes) {
|
||||
inputChannel->add_keycodes_supported(buttonCode);
|
||||
}
|
||||
|
||||
if (inputDevice_->hasTouchscreen()) {
|
||||
const auto &touchscreenSurface = inputDevice_->getTouchscreenGeometry();
|
||||
auto touchscreenConfig = inputChannel->add_touchscreen();
|
||||
|
||||
touchscreenConfig->set_width(touchscreenSurface.width());
|
||||
touchscreenConfig->set_height(touchscreenSurface.height());
|
||||
}
|
||||
}
|
||||
|
||||
void InputSourceService::onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) {
|
||||
OPENAUTO_LOG(info) << "[InputSourceService] onChannelOpenRequest()";
|
||||
OPENAUTO_LOG(debug) << "[InputSourceService] Channel Id: " << request.service_id() << ", Priority: " << request.priority();
|
||||
|
||||
|
||||
aap_protobuf::service::control::message::ChannelOpenResponse response;
|
||||
const aap_protobuf::shared::MessageStatus status = aap_protobuf::shared::MessageStatus::STATUS_SUCCESS;
|
||||
response.set_status(status);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {},
|
||||
std::bind(&InputSourceService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
channel_->sendChannelOpenResponse(response, std::move(promise));
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void InputSourceService::onKeyBindingRequest(const aap_protobuf::service::media::sink::message::KeyBindingRequest &request) {
|
||||
OPENAUTO_LOG(debug) << "[InputSourceService] onKeyBindingRequest()";
|
||||
OPENAUTO_LOG(debug) << "[InputSourceService] KeyCodes Count: " << request.keycodes_size();
|
||||
|
||||
aap_protobuf::shared::MessageStatus status = aap_protobuf::shared::MessageStatus::STATUS_SUCCESS;
|
||||
const auto &supportedButtonCodes = inputDevice_->getSupportedButtonCodes();
|
||||
|
||||
for (int i = 0; i < request.keycodes_size(); ++i) {
|
||||
if (std::find(supportedButtonCodes.begin(), supportedButtonCodes.end(), request.keycodes(i)) ==
|
||||
supportedButtonCodes.end()) {
|
||||
OPENAUTO_LOG(error) << "[InputSourceService] onKeyBindingRequest is not supported for KeyCode: " << request.keycodes(i);
|
||||
status = aap_protobuf::shared::MessageStatus::STATUS_KEYCODE_NOT_BOUND;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
aap_protobuf::service::media::sink::message::KeyBindingResponse response;
|
||||
response.set_status(status);
|
||||
|
||||
if (status == aap_protobuf::shared::MessageStatus::STATUS_SUCCESS) {
|
||||
inputDevice_->start(*this);
|
||||
}
|
||||
|
||||
OPENAUTO_LOG(debug) << "[InputSourceService] Sending KeyBindingResponse with Status: " << status;
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {},
|
||||
std::bind(&InputSourceService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
channel_->sendKeyBindingResponse(response, std::move(promise));
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void InputSourceService::onChannelError(const aasdk::error::Error &e) {
|
||||
OPENAUTO_LOG(error) << "[InputSourceService] onChannelError(): " << e.what();
|
||||
}
|
||||
|
||||
void InputSourceService::onButtonEvent(const projection::ButtonEvent &event) {
|
||||
OPENAUTO_LOG(error) << "[InputSourceService] onButtonEvent()";
|
||||
auto timestamp = std::chrono::duration_cast<std::chrono::microseconds>(
|
||||
std::chrono::high_resolution_clock::now().time_since_epoch());
|
||||
|
||||
strand_.dispatch(
|
||||
[this, self = this->shared_from_this(), event = std::move(event), timestamp = std::move(timestamp)]() {
|
||||
aap_protobuf::service::inputsource::message::InputReport inputReport;
|
||||
inputReport.set_timestamp(timestamp.count());
|
||||
|
||||
if (event.code == aap_protobuf::service::media::sink::message::KeyCode::KEYCODE_ROTARY_CONTROLLER) {
|
||||
auto relativeEvent = inputReport.mutable_relative_event()->add_data();
|
||||
relativeEvent->set_delta(event.wheelDirection == projection::WheelDirection::LEFT ? -1 : 1);
|
||||
relativeEvent->set_keycode(event.code);
|
||||
} else {
|
||||
auto buttonEvent = inputReport.mutable_key_event()->add_keys();
|
||||
buttonEvent->set_metastate(0);
|
||||
buttonEvent->set_down(event.type == projection::ButtonEventType::PRESS);
|
||||
buttonEvent->set_longpress(false);
|
||||
buttonEvent->set_keycode(event.code);
|
||||
}
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&InputSourceService::onChannelError, this->shared_from_this(),
|
||||
std::placeholders::_1));
|
||||
channel_->sendInputReport(inputReport, std::move(promise));
|
||||
});
|
||||
}
|
||||
|
||||
void InputSourceService::onTouchEvent(const projection::TouchEvent &event) {
|
||||
OPENAUTO_LOG(error) << "[InputSourceService] onTouchEvent()";
|
||||
auto timestamp = std::chrono::duration_cast<std::chrono::microseconds>(
|
||||
std::chrono::high_resolution_clock::now().time_since_epoch());
|
||||
|
||||
strand_.dispatch(
|
||||
[this, self = this->shared_from_this(), event = std::move(event), timestamp = std::move(timestamp)]() {
|
||||
aap_protobuf::service::inputsource::message::InputReport inputReport;
|
||||
inputReport.set_timestamp(timestamp.count());
|
||||
|
||||
auto touchEvent = inputReport.mutable_touch_event();
|
||||
touchEvent->set_action(event.type);
|
||||
auto touchLocation = touchEvent->add_pointer_data();
|
||||
touchLocation->set_x(event.x);
|
||||
touchLocation->set_y(event.y);
|
||||
touchLocation->set_pointer_id(0);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&InputSourceService::onChannelError, this->shared_from_this(),
|
||||
std::placeholders::_1));
|
||||
channel_->sendInputReport(inputReport, std::move(promise));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <aasdk/Channel/AV/MediaAudioServiceChannel.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/MediaAudioService.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace service
|
||||
{
|
||||
|
||||
MediaAudioService::MediaAudioService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IAudioOutput::Pointer audioOutput)
|
||||
: AudioService(ioService, std::make_shared<aasdk::channel::av::MediaAudioServiceChannel>(strand_, std::move(messenger)), std::move(audioOutput))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
95
src/autoapp/Service/MediaBrowser/MediaBrowserService.cpp
Normal file
95
src/autoapp/Service/MediaBrowser/MediaBrowserService.cpp
Normal file
@ -0,0 +1,95 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <f1x/openauto/Common/Log.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/MediaBrowser/MediaBrowserService.hpp>
|
||||
#include <fstream>
|
||||
#include <QString>
|
||||
|
||||
namespace f1x {
|
||||
namespace openauto {
|
||||
namespace autoapp {
|
||||
namespace service {
|
||||
namespace mediabrowser {
|
||||
|
||||
MediaBrowserService::MediaBrowserService(boost::asio::io_service &ioService,
|
||||
aasdk::messenger::IMessenger::Pointer messenger)
|
||||
: strand_(ioService),
|
||||
timer_(ioService),
|
||||
channel_(std::make_shared<aasdk::channel::mediabrowser::MediaBrowserService>(strand_, std::move(messenger))) {
|
||||
|
||||
}
|
||||
|
||||
void MediaBrowserService::start() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[MediaBrowserService] start()";
|
||||
});
|
||||
}
|
||||
|
||||
void MediaBrowserService::stop() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[MediaBrowserService] stop()";
|
||||
});
|
||||
}
|
||||
|
||||
void MediaBrowserService::pause() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[MediaBrowserService] pause()";
|
||||
});
|
||||
}
|
||||
|
||||
void MediaBrowserService::resume() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[MediaBrowserService] resume()";
|
||||
});
|
||||
}
|
||||
|
||||
void MediaBrowserService::fillFeatures(
|
||||
aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) {
|
||||
OPENAUTO_LOG(info) << "[MediaBrowserService] fillFeatures()";
|
||||
|
||||
auto *service = response.add_channels();
|
||||
service->set_id(static_cast<uint32_t>(channel_->getId()));
|
||||
|
||||
auto *mediaBrowser = service->mutable_media_browser_service();
|
||||
}
|
||||
|
||||
void MediaBrowserService::onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) {
|
||||
OPENAUTO_LOG(info) << "[MediaBrowserService] onChannelOpenRequest()";
|
||||
OPENAUTO_LOG(info) << "[MediaBrowserService] Channel Id: " << request.service_id() << ", Priority: " << request.priority();
|
||||
|
||||
aap_protobuf::service::control::message::ChannelOpenResponse response;
|
||||
const aap_protobuf::shared::MessageStatus status = aap_protobuf::shared::MessageStatus::STATUS_SUCCESS;
|
||||
response.set_status(status);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&MediaBrowserService::onChannelError, this->shared_from_this(),
|
||||
std::placeholders::_1));
|
||||
channel_->sendChannelOpenResponse(response, std::move(promise));
|
||||
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void MediaBrowserService::onChannelError(const aasdk::error::Error &e) {
|
||||
OPENAUTO_LOG(error) << "[MediaBrowserService] onChannelError(): " << e.what();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <f1x/openauto/Common/Log.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/MediaPlaybackStatus/MediaPlaybackStatusService.hpp>
|
||||
#include <fstream>
|
||||
#include <QString>
|
||||
|
||||
namespace f1x {
|
||||
namespace openauto {
|
||||
namespace autoapp {
|
||||
namespace service {
|
||||
namespace mediaplaybackstatus {
|
||||
|
||||
MediaPlaybackStatusService::MediaPlaybackStatusService(boost::asio::io_service &ioService,
|
||||
aasdk::messenger::IMessenger::Pointer messenger)
|
||||
: strand_(ioService),
|
||||
timer_(ioService),
|
||||
channel_(std::make_shared<aasdk::channel::mediaplaybackstatus::MediaPlaybackStatusService>(strand_, std::move(messenger))) {
|
||||
|
||||
}
|
||||
|
||||
void MediaPlaybackStatusService::start() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[MediaPlaybackStatusService] start()";
|
||||
});
|
||||
}
|
||||
|
||||
void MediaPlaybackStatusService::stop() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[MediaPlaybackStatusService] stop()";
|
||||
});
|
||||
}
|
||||
|
||||
void MediaPlaybackStatusService::pause() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[MediaPlaybackStatusService] pause()";
|
||||
});
|
||||
}
|
||||
|
||||
void MediaPlaybackStatusService::resume() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[MediaPlaybackStatusService] resume()";
|
||||
});
|
||||
}
|
||||
|
||||
void MediaPlaybackStatusService::fillFeatures(
|
||||
aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) {
|
||||
OPENAUTO_LOG(info) << "[MediaPlaybackStatusService] fillFeatures()";
|
||||
|
||||
auto *service = response.add_channels();
|
||||
service->set_id(static_cast<uint32_t>(channel_->getId()));
|
||||
|
||||
auto *mediaPlaybackStatus = service->mutable_media_playback_service();
|
||||
}
|
||||
|
||||
void MediaPlaybackStatusService::onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) {
|
||||
OPENAUTO_LOG(info) << "[MediaPlaybackStatusService] onChannelOpenRequest()";
|
||||
OPENAUTO_LOG(info) << "[MediaPlaybackStatusService] Channel Id: " << request.service_id() << ", Priority: " << request.priority();
|
||||
|
||||
aap_protobuf::service::control::message::ChannelOpenResponse response;
|
||||
const aap_protobuf::shared::MessageStatus status = aap_protobuf::shared::MessageStatus::STATUS_SUCCESS;
|
||||
response.set_status(status);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&MediaPlaybackStatusService::onChannelError, this->shared_from_this(),
|
||||
std::placeholders::_1));
|
||||
channel_->sendChannelOpenResponse(response, std::move(promise));
|
||||
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
|
||||
void MediaPlaybackStatusService::onChannelError(const aasdk::error::Error &e) {
|
||||
OPENAUTO_LOG(error) << "[MediaPlaybackStatusService] onChannelError(): " << e.what();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
226
src/autoapp/Service/MediaSink/AudioMediaSinkService.cpp
Normal file
226
src/autoapp/Service/MediaSink/AudioMediaSinkService.cpp
Normal file
@ -0,0 +1,226 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <f1x/openauto/Common/Log.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/MediaSink/AudioMediaSinkService.hpp>
|
||||
|
||||
namespace f1x {
|
||||
namespace openauto {
|
||||
namespace autoapp {
|
||||
namespace service {
|
||||
namespace mediasink {
|
||||
|
||||
AudioMediaSinkService::AudioMediaSinkService(boost::asio::io_service &ioService,
|
||||
aasdk::channel::mediasink::audio::IAudioMediaSinkService::Pointer channel,
|
||||
projection::IAudioOutput::Pointer audioOutput)
|
||||
: strand_(ioService), channel_(std::move(channel)), audioOutput_(std::move(audioOutput)), session_(-1) {
|
||||
|
||||
}
|
||||
|
||||
void AudioMediaSinkService::start() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[AudioMediaSinkService] start()";
|
||||
OPENAUTO_LOG(info) << "[AudioMediaSinkService] Channel " << aasdk::messenger::channelIdToString(channel_->getId());
|
||||
channel_->receive(this->shared_from_this());
|
||||
});
|
||||
}
|
||||
|
||||
void AudioMediaSinkService::stop() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[AudioMediaSinkService] stop()";
|
||||
OPENAUTO_LOG(info) << "[AudioMediaSinkService] Channel " << aasdk::messenger::channelIdToString(channel_->getId());
|
||||
audioOutput_->stop();
|
||||
});
|
||||
}
|
||||
|
||||
void AudioMediaSinkService::pause() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[AudioMediaSinkService] pause()";
|
||||
OPENAUTO_LOG(info) << "[AudioMediaSinkService] Channel " << aasdk::messenger::channelIdToString(channel_->getId());
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
void AudioMediaSinkService::resume() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[AudioMediaSinkService] resume()";
|
||||
OPENAUTO_LOG(info) << "[AudioMediaSinkService] Channel " << aasdk::messenger::channelIdToString(channel_->getId());
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* Service Discovery
|
||||
*/
|
||||
|
||||
void AudioMediaSinkService::fillFeatures(
|
||||
aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) {
|
||||
OPENAUTO_LOG(info) << "[AudioMediaSinkService] fillFeatures()";
|
||||
OPENAUTO_LOG(info) << "[AudioMediaSinkService] Channel: " << aasdk::messenger::channelIdToString(channel_->getId());
|
||||
|
||||
auto *service = response.add_channels();
|
||||
service->set_id(static_cast<uint32_t>(channel_->getId()));
|
||||
|
||||
auto audioChannel = service->mutable_media_sink_service();
|
||||
|
||||
audioChannel->set_available_type(
|
||||
aap_protobuf::service::media::shared::message::MediaCodecType::MEDIA_CODEC_AUDIO_PCM);
|
||||
|
||||
switch (channel_->getId()) {
|
||||
case aasdk::messenger::ChannelId::MEDIA_SINK_SYSTEM_AUDIO:
|
||||
OPENAUTO_LOG(info) << "[AudioMediaSinkService] System Audio.";
|
||||
audioChannel->set_audio_type(
|
||||
aap_protobuf::service::media::sink::message::AudioStreamType::AUDIO_STREAM_SYSTEM_AUDIO);
|
||||
break;
|
||||
|
||||
case aasdk::messenger::ChannelId::MEDIA_SINK_MEDIA_AUDIO:
|
||||
OPENAUTO_LOG(info) << "[AudioMediaSinkService] Music Audio.";
|
||||
audioChannel->set_audio_type(aap_protobuf::service::media::sink::message::AudioStreamType::AUDIO_STREAM_MEDIA);
|
||||
break;
|
||||
|
||||
case aasdk::messenger::ChannelId::MEDIA_SINK_GUIDANCE_AUDIO:
|
||||
OPENAUTO_LOG(info) << "[AudioMediaSinkService] Guidance Audio.";
|
||||
audioChannel->set_audio_type(
|
||||
aap_protobuf::service::media::sink::message::AudioStreamType::AUDIO_STREAM_GUIDANCE);
|
||||
break;
|
||||
|
||||
case aasdk::messenger::ChannelId::MEDIA_SINK_TELEPHONY_AUDIO:
|
||||
OPENAUTO_LOG(info) << "[AudioMediaSinkService] Telephony Audio.";
|
||||
audioChannel->set_audio_type(
|
||||
aap_protobuf::service::media::sink::message::AudioStreamType::AUDIO_STREAM_TELEPHONY);
|
||||
break;
|
||||
default:
|
||||
OPENAUTO_LOG(info) << "[AudioMediaSinkService] Unknown Audio.";
|
||||
break;
|
||||
}
|
||||
|
||||
audioChannel->set_available_while_in_call(true);
|
||||
|
||||
auto *audioConfig = audioChannel->add_audio_configs();
|
||||
audioConfig->set_sampling_rate(audioOutput_->getSampleRate());
|
||||
audioConfig->set_number_of_bits(audioOutput_->getSampleSize());
|
||||
audioConfig->set_number_of_channels(audioOutput_->getChannelCount());
|
||||
|
||||
OPENAUTO_LOG(info) << "[AudioMediaSinkService] getSampleRate " << audioOutput_->getSampleRate();
|
||||
OPENAUTO_LOG(info) << "[AudioMediaSinkService] getSampleSize " << audioOutput_->getSampleSize();
|
||||
OPENAUTO_LOG(info) << "[AudioMediaSinkService] getChannelCount " << audioOutput_->getChannelCount();
|
||||
//OPENAUTO_LOG(info) << "[AudioMediaSinkService] SampleRate " << audioConfig->sampling_rate() << " / " << audioConfig->number_of_bits() << " / " << audioConfig->number_of_channels();
|
||||
}
|
||||
|
||||
/*
|
||||
* Base Channel Handling
|
||||
*/
|
||||
|
||||
void AudioMediaSinkService::onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) {
|
||||
OPENAUTO_LOG(info) << "[AudioMediaSinkService] onChannelOpenRequest()";
|
||||
OPENAUTO_LOG(info) << "[AudioMediaSinkService] Channel Id: " << request.service_id() << ", Priority: " << request.priority();
|
||||
|
||||
OPENAUTO_LOG(info) << "[AudioMediaSinkService] Sample Rate: " << audioOutput_->getSampleRate() << ", Sample Size: " << audioOutput_->getSampleSize() << ", Audio Channels: " << audioOutput_->getChannelCount();
|
||||
|
||||
const aap_protobuf::shared::MessageStatus status = audioOutput_->open()
|
||||
? aap_protobuf::shared::MessageStatus::STATUS_SUCCESS
|
||||
: aap_protobuf::shared::MessageStatus::STATUS_INVALID_CHANNEL;
|
||||
|
||||
OPENAUTO_LOG(debug) << "[AudioMediaSinkService] Status determined: " << aap_protobuf::shared::MessageStatus_Name(status);
|
||||
|
||||
aap_protobuf::service::control::message::ChannelOpenResponse response;
|
||||
response.set_status(status);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&AudioMediaSinkService::onChannelError, this->shared_from_this(),
|
||||
std::placeholders::_1));
|
||||
channel_->sendChannelOpenResponse(response, std::move(promise));
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void AudioMediaSinkService::onChannelError(const aasdk::error::Error &e) {
|
||||
OPENAUTO_LOG(error) << "[AudioMediaSinkService] onChannelError(): " << e.what()
|
||||
<< ", channel: " << aasdk::messenger::channelIdToString(channel_->getId());
|
||||
}
|
||||
|
||||
/*
|
||||
* Media Channel Handling
|
||||
*/
|
||||
|
||||
void AudioMediaSinkService::onMediaChannelSetupRequest(const aap_protobuf::service::media::shared::message::Setup &request) {
|
||||
OPENAUTO_LOG(info) << "[AudioMediaSinkService] onMediaChannelSetupRequest()";
|
||||
OPENAUTO_LOG(info) << "[AudioMediaSinkService] Channel Id: " << aasdk::messenger::channelIdToString(channel_->getId()) << ", Codec: " << MediaCodecType_Name(request.type());
|
||||
|
||||
aap_protobuf::service::media::shared::message::Config response;
|
||||
auto status = aap_protobuf::service::media::shared::message::Config::STATUS_READY;
|
||||
response.set_status(status);
|
||||
response.set_max_unacked(1);
|
||||
response.add_configuration_indices(0);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
|
||||
promise->then([]() {}, std::bind(&AudioMediaSinkService::onChannelError, this->shared_from_this(),
|
||||
std::placeholders::_1));
|
||||
channel_->sendChannelSetupResponse(response, std::move(promise));
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
|
||||
void AudioMediaSinkService::onMediaChannelStartIndication(const aap_protobuf::service::media::shared::message::Start &indication) {
|
||||
OPENAUTO_LOG(info) << "[AudioMediaSinkService] onMediaChannelStartIndication()";
|
||||
OPENAUTO_LOG(info) << "[AudioMediaSinkService] Channel Id: " << aasdk::messenger::channelIdToString(channel_->getId()) << ", session: " << indication.session_id();
|
||||
session_ = indication.session_id();
|
||||
audioOutput_->start();
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void AudioMediaSinkService::onMediaChannelStopIndication(const aap_protobuf::service::media::shared::message::Stop &indication) {
|
||||
OPENAUTO_LOG(info) << "[AudioMediaSinkService] onMediaChannelStopIndication()";
|
||||
OPENAUTO_LOG(info) << "[AudioMediaSinkService] Channel Id: " << aasdk::messenger::channelIdToString(channel_->getId()) << ", session: " << session_;
|
||||
|
||||
session_ = -1;
|
||||
audioOutput_->suspend();
|
||||
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void AudioMediaSinkService::onMediaWithTimestampIndication(aasdk::messenger::Timestamp::ValueType timestamp,
|
||||
const aasdk::common::DataConstBuffer &buffer) {
|
||||
OPENAUTO_LOG(debug) << "[AudioMediaSinkService] onMediaWithTimestampIndication()";
|
||||
OPENAUTO_LOG(debug) << "[AudioMediaSinkService] Channel Id: " << aasdk::messenger::channelIdToString(channel_->getId()) << ", session: " << session_;
|
||||
|
||||
audioOutput_->write(timestamp, buffer);
|
||||
|
||||
aap_protobuf::service::media::source::message::Ack indication;
|
||||
indication.set_session_id(session_);
|
||||
indication.set_ack(1);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&AudioMediaSinkService::onChannelError, this->shared_from_this(),
|
||||
std::placeholders::_1));
|
||||
channel_->sendMediaAckIndication(indication, std::move(promise));
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void AudioMediaSinkService::onMediaIndication(const aasdk::common::DataConstBuffer &buffer) {
|
||||
OPENAUTO_LOG(info) << "[AudioMediaSinkService] onMediaIndication()";
|
||||
|
||||
this->onMediaWithTimestampIndication(0, buffer);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
39
src/autoapp/Service/MediaSink/GuidanceAudioService.cpp
Normal file
39
src/autoapp/Service/MediaSink/GuidanceAudioService.cpp
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <f1x/openauto/autoapp/Service/MediaSink/GuidanceAudioService.hpp>
|
||||
|
||||
|
||||
namespace f1x::openauto::autoapp::service::mediasink {
|
||||
using f1x::openauto::autoapp::service::mediasink::GuidanceAudioService;
|
||||
using f1x::openauto::autoapp::service::mediasink::AudioMediaSinkService;
|
||||
using aasdk::channel::mediasink::audio::channel::GuidanceAudioChannel;
|
||||
|
||||
GuidanceAudioService::GuidanceAudioService(boost::asio::io_service &ioService,
|
||||
aasdk::messenger::IMessenger::Pointer messenger,
|
||||
projection::IAudioOutput::Pointer audioOutput)
|
||||
: AudioMediaSinkService(
|
||||
ioService,
|
||||
std::make_shared<GuidanceAudioChannel>(strand_, std::move(messenger)),
|
||||
std::move(audioOutput)) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
36
src/autoapp/Service/MediaSink/MediaAudioService.cpp
Normal file
36
src/autoapp/Service/MediaSink/MediaAudioService.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <f1x/openauto/autoapp/Service/MediaSink/MediaAudioService.hpp>
|
||||
|
||||
|
||||
namespace f1x::openauto::autoapp::service::mediasink {
|
||||
MediaAudioService::MediaAudioService(boost::asio::io_service &ioService,
|
||||
aasdk::messenger::IMessenger::Pointer messenger,
|
||||
projection::IAudioOutput::Pointer audioOutput)
|
||||
: AudioMediaSinkService(ioService,
|
||||
std::make_shared<aasdk::channel::mediasink::audio::channel::MediaAudioChannel>(strand_,
|
||||
std::move(
|
||||
messenger)),
|
||||
std::move(audioOutput)) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
38
src/autoapp/Service/MediaSink/SystemAudioService.cpp
Normal file
38
src/autoapp/Service/MediaSink/SystemAudioService.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <aasdk/Channel/MediaSink/Audio/Channel/SystemAudioChannel.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/MediaSink/SystemAudioService.hpp>
|
||||
|
||||
|
||||
namespace f1x::openauto::autoapp::service::mediasink {
|
||||
SystemAudioService::SystemAudioService(boost::asio::io_service &ioService,
|
||||
aasdk::messenger::IMessenger::Pointer messenger,
|
||||
projection::IAudioOutput::Pointer audioOutput)
|
||||
: AudioMediaSinkService(ioService,
|
||||
std::make_shared<aasdk::channel::mediasink::audio::channel::SystemAudioChannel>(strand_,
|
||||
std::move(
|
||||
messenger)),
|
||||
std::move(audioOutput)) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
40
src/autoapp/Service/MediaSink/TelephonyAudioService.cpp
Normal file
40
src/autoapp/Service/MediaSink/TelephonyAudioService.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <aasdk/Channel/MediaSink/Audio/Channel/TelephonyAudioChannel.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/MediaSink/TelephonyAudioService.hpp>
|
||||
|
||||
namespace f1x {
|
||||
namespace openauto {
|
||||
namespace autoapp {
|
||||
namespace service {
|
||||
namespace mediasink {
|
||||
TelephonyAudioService::TelephonyAudioService(boost::asio::io_service &ioService,
|
||||
aasdk::messenger::IMessenger::Pointer messenger,
|
||||
projection::IAudioOutput::Pointer audioOutput)
|
||||
: AudioMediaSinkService(ioService, std::make_shared<aasdk::channel::mediasink::audio::channel::TelephonyAudioChannel>(strand_,
|
||||
std::move(
|
||||
messenger)),
|
||||
std::move(audioOutput)) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
239
src/autoapp/Service/MediaSink/VideoMediaSinkService.cpp
Normal file
239
src/autoapp/Service/MediaSink/VideoMediaSinkService.cpp
Normal file
@ -0,0 +1,239 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <fstream>
|
||||
#include <f1x/openauto/autoapp/Service/MediaSink/VideoMediaSinkService.hpp>
|
||||
|
||||
namespace f1x {
|
||||
namespace openauto {
|
||||
namespace autoapp {
|
||||
namespace service {
|
||||
namespace mediasink {
|
||||
VideoMediaSinkService::VideoMediaSinkService(boost::asio::io_service &ioService,
|
||||
aasdk::channel::mediasink::video::IVideoMediaSinkService::Pointer channel,
|
||||
projection::IVideoOutput::Pointer videoOutput)
|
||||
: strand_(ioService), channel_(std::move(channel)), videoOutput_(std::move(videoOutput)), session_(-1) {
|
||||
|
||||
}
|
||||
|
||||
void VideoMediaSinkService::start() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[VideoMediaSinkService] start()";
|
||||
OPENAUTO_LOG(info) << "[VideoMediaSinkService] Channel "
|
||||
<< aasdk::messenger::channelIdToString(channel_->getId());
|
||||
channel_->receive(this->shared_from_this());
|
||||
});
|
||||
}
|
||||
|
||||
void VideoMediaSinkService::stop() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[VideoMediaSinkService] stop()";
|
||||
OPENAUTO_LOG(info) << "[VideoMediaSinkService] Channel "
|
||||
<< aasdk::messenger::channelIdToString(channel_->getId());
|
||||
videoOutput_->stop();
|
||||
});
|
||||
}
|
||||
|
||||
void VideoMediaSinkService::pause() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[VideoMediaSinkService] pause()";
|
||||
OPENAUTO_LOG(info) << "[VideoMediaSinkService] Channel "
|
||||
<< aasdk::messenger::channelIdToString(channel_->getId());
|
||||
});
|
||||
}
|
||||
|
||||
void VideoMediaSinkService::resume() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[VideoMediaSinkService] resume()";
|
||||
OPENAUTO_LOG(info) << "[VideoMediaSinkService] Channel "
|
||||
<< aasdk::messenger::channelIdToString(channel_->getId());
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
void VideoMediaSinkService::fillFeatures(
|
||||
aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) {
|
||||
OPENAUTO_LOG(info) << "[VideoMediaSinkService] fillFeatures()";
|
||||
OPENAUTO_LOG(info) << "[VideoMediaSinkService] Channel "
|
||||
<< aasdk::messenger::channelIdToString(channel_->getId());
|
||||
|
||||
auto *service = response.add_channels();
|
||||
service->set_id(static_cast<uint32_t>(channel_->getId()));
|
||||
|
||||
auto *videoChannel = service->mutable_media_sink_service();
|
||||
|
||||
videoChannel->set_available_type(
|
||||
aap_protobuf::service::media::shared::message::MediaCodecType::MEDIA_CODEC_VIDEO_H264_BP);
|
||||
videoChannel->set_available_while_in_call(true);
|
||||
|
||||
|
||||
auto *videoConfig1 = videoChannel->add_video_configs();
|
||||
videoConfig1->set_codec_resolution(videoOutput_->getVideoResolution());
|
||||
videoConfig1->set_frame_rate(videoOutput_->getVideoFPS());
|
||||
|
||||
const auto &videoMargins = videoOutput_->getVideoMargins();
|
||||
videoConfig1->set_height_margin(videoMargins.height());
|
||||
videoConfig1->set_width_margin(videoMargins.width());
|
||||
videoConfig1->set_density(videoOutput_->getScreenDPI());
|
||||
|
||||
OPENAUTO_LOG(info) << "[VideoMediaSinkService] getVideoResolution " << VideoCodecResolutionType_Name(videoOutput_->getVideoResolution());
|
||||
OPENAUTO_LOG(info) << "[VideoMediaSinkService] getVideoFPS " << VideoFrameRateType_Name(videoOutput_->getVideoFPS());
|
||||
OPENAUTO_LOG(info) << "[VideoMediaSinkService] width " << videoMargins.width();
|
||||
OPENAUTO_LOG(info) << "[VideoMediaSinkService] height " << videoMargins.height();
|
||||
OPENAUTO_LOG(info) << "[VideoMediaSinkService] getScreenDPI " << videoOutput_->getScreenDPI();
|
||||
}
|
||||
|
||||
void
|
||||
VideoMediaSinkService::onMediaChannelSetupRequest(const aap_protobuf::service::media::shared::message::Setup &request) {
|
||||
OPENAUTO_LOG(info) << "[VideoMediaSinkService] onMediaChannelSetupRequest()";
|
||||
OPENAUTO_LOG(info) << "[VideoMediaSinkService] Channel Id: "
|
||||
<< aasdk::messenger::channelIdToString(channel_->getId()) << ", Codec: "
|
||||
<< MediaCodecType_Name(request.type());
|
||||
|
||||
|
||||
auto status = videoOutput_->init()
|
||||
? aap_protobuf::service::media::shared::message::Config::STATUS_READY
|
||||
: aap_protobuf::service::media::shared::message::Config::STATUS_WAIT;
|
||||
|
||||
OPENAUTO_LOG(debug) << "[VideoMediaSinkService] setup status: " << Config_Status_Name(status);
|
||||
|
||||
aap_protobuf::service::media::shared::message::Config response;
|
||||
response.set_status(status);
|
||||
response.set_max_unacked(1);
|
||||
response.add_configuration_indices(0);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then(std::bind(&VideoMediaSinkService::sendVideoFocusIndication, this->shared_from_this()),
|
||||
std::bind(&VideoMediaSinkService::onChannelError, this->shared_from_this(),
|
||||
std::placeholders::_1));
|
||||
|
||||
channel_->sendChannelSetupResponse(response, std::move(promise));
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void VideoMediaSinkService::onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) {
|
||||
OPENAUTO_LOG(info) << "[VideoMediaSinkService] onChannelOpenRequest()";
|
||||
OPENAUTO_LOG(info) << "[VideoMediaSinkService] Channel Id: " << request.service_id() << ", Priority: "
|
||||
<< request.priority();
|
||||
|
||||
const aap_protobuf::shared::MessageStatus status = videoOutput_->open()
|
||||
? aap_protobuf::shared::MessageStatus::STATUS_SUCCESS
|
||||
: aap_protobuf::shared::MessageStatus::STATUS_INTERNAL_ERROR;
|
||||
|
||||
OPENAUTO_LOG(info) << "[VideoMediaSinkService] Status determined: "
|
||||
<< aap_protobuf::shared::MessageStatus_Name(status);
|
||||
|
||||
aap_protobuf::service::control::message::ChannelOpenResponse response;
|
||||
response.set_status(status);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&VideoMediaSinkService::onChannelError, this->shared_from_this(),
|
||||
std::placeholders::_1));
|
||||
channel_->sendChannelOpenResponse(response, std::move(promise));
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void VideoMediaSinkService::onMediaChannelStartIndication(
|
||||
const aap_protobuf::service::media::shared::message::Start &indication) {
|
||||
OPENAUTO_LOG(info) << "[VideoMediaSinkService] onMediaChannelStartIndication()";
|
||||
OPENAUTO_LOG(info) << "[VideoMediaSinkService] Channel Id: "
|
||||
<< aasdk::messenger::channelIdToString(channel_->getId()) << ", session: "
|
||||
<< indication.session_id();
|
||||
|
||||
session_ = indication.session_id();
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void VideoMediaSinkService::onMediaChannelStopIndication(
|
||||
const aap_protobuf::service::media::shared::message::Stop &indication) {
|
||||
OPENAUTO_LOG(info) << "[onMediaChannelStopIndication] onMediaChannelStopIndication()";
|
||||
OPENAUTO_LOG(info) << "[onMediaChannelStopIndication] Channel Id: "
|
||||
<< aasdk::messenger::channelIdToString(channel_->getId()) << ", session: " << session_;
|
||||
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void VideoMediaSinkService::onMediaWithTimestampIndication(aasdk::messenger::Timestamp::ValueType timestamp,
|
||||
const aasdk::common::DataConstBuffer &buffer) {
|
||||
OPENAUTO_LOG(debug) << "[VideoMediaSinkService] onMediaWithTimestampIndication()";
|
||||
OPENAUTO_LOG(debug) << "[VideoMediaSinkService] Channel Id: "
|
||||
<< aasdk::messenger::channelIdToString(channel_->getId()) << ", session: " << session_;
|
||||
|
||||
videoOutput_->write(timestamp, buffer);
|
||||
|
||||
aap_protobuf::service::media::source::message::Ack indication;
|
||||
indication.set_session_id(session_);
|
||||
indication.set_ack(1);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&VideoMediaSinkService::onChannelError, this->shared_from_this(),
|
||||
std::placeholders::_1));
|
||||
channel_->sendMediaAckIndication(indication, std::move(promise));
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void VideoMediaSinkService::onMediaIndication(const aasdk::common::DataConstBuffer &buffer) {
|
||||
OPENAUTO_LOG(debug) << "[VideoMediaSinkService] onMediaIndication()";
|
||||
this->onMediaWithTimestampIndication(0, buffer);
|
||||
}
|
||||
|
||||
void VideoMediaSinkService::onChannelError(const aasdk::error::Error &e) {
|
||||
OPENAUTO_LOG(error) << "[VideoMediaSinkService] onChannelError(): " << e.what()
|
||||
<< ", channel: " << aasdk::messenger::channelIdToString(channel_->getId());
|
||||
}
|
||||
|
||||
void VideoMediaSinkService::onVideoFocusRequest(
|
||||
const aap_protobuf::service::media::video::message::VideoFocusRequestNotification &request) {
|
||||
OPENAUTO_LOG(info) << "[VideoMediaSinkService] onVideoFocusRequest()";
|
||||
OPENAUTO_LOG(info) << "[VideoMediaSinkService] Display index: " << request.disp_channel_id() << ", focus mode: " << VideoFocusMode_Name(request.mode()) << ", focus reason: " << VideoFocusReason_Name(request.reason());
|
||||
|
||||
if (request.mode() ==
|
||||
aap_protobuf::service::media::video::message::VideoFocusMode::VIDEO_FOCUS_NATIVE) {
|
||||
// Return to OS
|
||||
OPENAUTO_LOG(info) << "[VideoMediaSinkService] Returning to OS.";
|
||||
try {
|
||||
if (!std::ifstream("/tmp/entityexit")) {
|
||||
std::ofstream("/tmp/entityexit");
|
||||
}
|
||||
} catch (...) {
|
||||
OPENAUTO_LOG(error) << "[VideoMediaSinkService] Error in creating /tmp/entityexit";
|
||||
}
|
||||
}
|
||||
|
||||
this->sendVideoFocusIndication();
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void VideoMediaSinkService::sendVideoFocusIndication() {
|
||||
OPENAUTO_LOG(info) << "[VideoMediaSinkService] sendVideoFocusIndication()";
|
||||
|
||||
aap_protobuf::service::media::video::message::VideoFocusNotification videoFocusIndication;
|
||||
videoFocusIndication.set_focus(
|
||||
aap_protobuf::service::media::video::message::VideoFocusMode::VIDEO_FOCUS_PROJECTED);
|
||||
videoFocusIndication.set_unsolicited(false);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() { }, std::bind(&VideoMediaSinkService::onChannelError, this->shared_from_this(),
|
||||
std::placeholders::_1));
|
||||
channel_->sendVideoFocusIndication(videoFocusIndication, std::move(promise));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
40
src/autoapp/Service/MediaSink/VideoService.cpp
Normal file
40
src/autoapp/Service/MediaSink/VideoService.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <aasdk/Channel/MediaSink/Video/Channel/VideoChannel.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/MediaSink/VideoService.hpp>
|
||||
|
||||
namespace f1x {
|
||||
namespace openauto {
|
||||
namespace autoapp {
|
||||
namespace service {
|
||||
namespace mediasink {
|
||||
VideoService::VideoService(boost::asio::io_service &ioService,
|
||||
aasdk::messenger::IMessenger::Pointer messenger,
|
||||
projection::IVideoOutput::Pointer videoOutput)
|
||||
: VideoMediaSinkService(ioService, std::make_shared<aasdk::channel::mediasink::video::channel::VideoChannel>(strand_,
|
||||
std::move(
|
||||
messenger)),
|
||||
std::move(videoOutput)) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
273
src/autoapp/Service/MediaSource/MediaSourceService.cpp
Normal file
273
src/autoapp/Service/MediaSource/MediaSourceService.cpp
Normal file
@ -0,0 +1,273 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <f1x/openauto/Common/Log.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/MediaSource/MediaSourceService.hpp>
|
||||
|
||||
|
||||
namespace f1x::openauto::autoapp::service::mediasource {
|
||||
|
||||
MediaSourceService::MediaSourceService(boost::asio::io_service &ioService,
|
||||
aasdk::channel::mediasource::IMediaSourceService::Pointer channel,
|
||||
projection::IAudioInput::Pointer audioInput)
|
||||
: strand_(ioService), channel_(std::move(channel)), audioInput_(std::move(audioInput)), session_(-1) {
|
||||
|
||||
}
|
||||
|
||||
void MediaSourceService::start() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[MediaSourceService] start()";
|
||||
channel_->receive(this->shared_from_this());
|
||||
});
|
||||
}
|
||||
|
||||
void MediaSourceService::stop() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[MediaSourceService] stop()";
|
||||
audioInput_->stop();
|
||||
});
|
||||
}
|
||||
|
||||
void MediaSourceService::pause() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[MediaSourceService] pause()";
|
||||
});
|
||||
}
|
||||
|
||||
void MediaSourceService::resume() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[MediaSourceService] resume()";
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* Service Discovery
|
||||
*/
|
||||
|
||||
/**
|
||||
* Fill Features of Service
|
||||
* @param response
|
||||
*/
|
||||
void MediaSourceService::fillFeatures(
|
||||
aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) {
|
||||
OPENAUTO_LOG(info) << "[MediaSourceService] fillFeatures()";
|
||||
|
||||
auto *service = response.add_channels();
|
||||
service->set_id(static_cast<uint32_t>(channel_->getId()));
|
||||
|
||||
auto *avInputChannel = service->mutable_media_source_service();
|
||||
avInputChannel->set_available_type(
|
||||
aap_protobuf::service::media::shared::message::MediaCodecType::MEDIA_CODEC_AUDIO_PCM);
|
||||
|
||||
auto audioConfig = avInputChannel->mutable_audio_config();
|
||||
audioConfig->set_sampling_rate(audioInput_->getSampleRate());
|
||||
audioConfig->set_number_of_bits(audioInput_->getSampleSize());
|
||||
audioConfig->set_number_of_channels(audioInput_->getChannelCount());
|
||||
}
|
||||
|
||||
/*
|
||||
* Base Channel Handling
|
||||
*/
|
||||
|
||||
/**
|
||||
* Open Service Channel Request
|
||||
* @param request
|
||||
*/
|
||||
void
|
||||
MediaSourceService::onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) {
|
||||
OPENAUTO_LOG(info) << "[MediaSourceService] onChannelOpenRequest()";
|
||||
OPENAUTO_LOG(info) << "[MediaSourceService] Channel Id: " << request.service_id() << ", Priority: "
|
||||
<< request.priority();
|
||||
|
||||
const aap_protobuf::shared::MessageStatus status = audioInput_->open()
|
||||
? aap_protobuf::shared::MessageStatus::STATUS_SUCCESS
|
||||
: aap_protobuf::shared::MessageStatus::STATUS_INTERNAL_ERROR;
|
||||
|
||||
OPENAUTO_LOG(info) << "[MediaSourceService] Status determined: "
|
||||
<< aap_protobuf::shared::MessageStatus_Name(status);
|
||||
|
||||
aap_protobuf::service::control::message::ChannelOpenResponse response;
|
||||
response.set_status(status);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {},
|
||||
std::bind(&MediaSourceService::onChannelError, this->shared_from_this(),
|
||||
std::placeholders::_1));
|
||||
|
||||
channel_->sendChannelOpenResponse(response, std::move(promise));
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic Channel Error
|
||||
* @param e
|
||||
*/
|
||||
void MediaSourceService::onChannelError(const aasdk::error::Error &e) {
|
||||
OPENAUTO_LOG(error) << "[MediaSourceService] onChannelError(): " << e.what();
|
||||
}
|
||||
|
||||
/*
|
||||
* Media Channel Handling
|
||||
*/
|
||||
|
||||
/**
|
||||
* Generic Media Channel Setup Request
|
||||
* @param request
|
||||
*/
|
||||
void
|
||||
MediaSourceService::onMediaChannelSetupRequest(const aap_protobuf::service::media::shared::message::Setup &request) {
|
||||
|
||||
OPENAUTO_LOG(info) << "[MediaSourceService] onMediaChannelSetupRequest()";
|
||||
OPENAUTO_LOG(info) << "[MediaSourceService] Channel Id: " << aasdk::messenger::channelIdToString(channel_->getId())
|
||||
<< ", Codec: " << MediaCodecType_Name(request.type());
|
||||
|
||||
aap_protobuf::service::media::shared::message::Config response;
|
||||
auto status = aap_protobuf::service::media::shared::message::Config::STATUS_READY;
|
||||
response.set_status(status);
|
||||
response.set_max_unacked(1);
|
||||
response.add_configuration_indices(0);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
|
||||
promise->then([]() {}, std::bind(&MediaSourceService::onChannelError, this->shared_from_this(),
|
||||
std::placeholders::_1));
|
||||
channel_->sendChannelSetupResponse(response, std::move(promise));
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic Media Ack
|
||||
*/
|
||||
void MediaSourceService::onMediaChannelAckIndication(
|
||||
const aap_protobuf::service::media::source::message::Ack &) {
|
||||
OPENAUTO_LOG(debug) << "[MediaSourceService] onMediaChannelAckIndication()";
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
/*
|
||||
* Source Media Channel Handling
|
||||
*/
|
||||
|
||||
/**
|
||||
* Handle request to Open or Close Microphone Source Channel
|
||||
* @param request
|
||||
*/
|
||||
void MediaSourceService::onMediaSourceOpenRequest(
|
||||
const aap_protobuf::service::media::source::message::MicrophoneRequest &request) {
|
||||
OPENAUTO_LOG(info) << "[MediaSourceService] onMediaSourceOpenRequest()";
|
||||
OPENAUTO_LOG(info) << "[MediaSourceService] Request to Open?: " << request.open() << ", anc: "
|
||||
<< request.anc_enabled() << ", ec: " << request.ec_enabled() << ", max unacked: "
|
||||
<< request.max_unacked();
|
||||
|
||||
if (request.open()) {
|
||||
// Request for Channel Open
|
||||
auto startPromise = projection::IAudioInput::StartPromise::defer(strand_);
|
||||
startPromise->then(std::bind(&MediaSourceService::onMediaSourceOpenSuccess, this->shared_from_this()),
|
||||
[this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(error) << "[MediaSourceService] Media Source Open Failed";
|
||||
|
||||
aap_protobuf::service::media::source::message::MicrophoneResponse response;
|
||||
response.set_session_id(session_);
|
||||
|
||||
response.set_status(aap_protobuf::shared::MessageStatus::STATUS_INTERNAL_ERROR);
|
||||
|
||||
auto sendPromise = aasdk::channel::SendPromise::defer(strand_);
|
||||
sendPromise->then([]() {},
|
||||
std::bind(&MediaSourceService::onChannelError,
|
||||
this->shared_from_this(),
|
||||
std::placeholders::_1));
|
||||
channel_->sendMicrophoneOpenResponse(response, std::move(sendPromise));
|
||||
});
|
||||
|
||||
audioInput_->start(std::move(startPromise));
|
||||
} else {
|
||||
// Request for Channel Close
|
||||
audioInput_->stop();
|
||||
|
||||
aap_protobuf::service::media::source::message::MicrophoneResponse response;
|
||||
response.set_session_id(session_);
|
||||
|
||||
response.set_status(aap_protobuf::shared::MessageStatus::STATUS_SUCCESS);
|
||||
|
||||
auto sendPromise = aasdk::channel::SendPromise::defer(strand_);
|
||||
sendPromise->then([]() {}, std::bind(&MediaSourceService::onChannelError, this->shared_from_this(),
|
||||
std::placeholders::_1));
|
||||
channel_->sendMicrophoneOpenResponse(response, std::move(sendPromise));
|
||||
}
|
||||
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sends response to advise Microphone is Open
|
||||
*/
|
||||
void MediaSourceService::onMediaSourceOpenSuccess() {
|
||||
OPENAUTO_LOG(error) << "[MediaSourceService] onMediaSourceOpenSuccess()";
|
||||
|
||||
aap_protobuf::service::media::source::message::MicrophoneResponse response;
|
||||
response.set_session_id(session_);
|
||||
response.set_status(aap_protobuf::shared::MessageStatus::STATUS_SUCCESS);
|
||||
|
||||
auto sendPromise = aasdk::channel::SendPromise::defer(strand_);
|
||||
sendPromise->then([]() {}, std::bind(&MediaSourceService::onChannelError, this->shared_from_this(),
|
||||
std::placeholders::_1));
|
||||
|
||||
channel_->sendMicrophoneOpenResponse(response, std::move(sendPromise));
|
||||
|
||||
this->readMediaSource();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves promise from readMediaSource. Sends Media with Timestamp Indication to channel.
|
||||
* @param data
|
||||
*/
|
||||
void MediaSourceService::onMediaSourceDataReady(aasdk::common::Data data) {
|
||||
OPENAUTO_LOG(error) << "[MediaSourceService] onMediaSourceDataReady()";
|
||||
auto sendPromise = aasdk::channel::SendPromise::defer(strand_);
|
||||
sendPromise->then(std::bind(&MediaSourceService::readMediaSource, this->shared_from_this()),
|
||||
std::bind(&MediaSourceService::onChannelError, this->shared_from_this(),
|
||||
std::placeholders::_1));
|
||||
|
||||
auto timestamp = std::chrono::duration_cast<std::chrono::microseconds>(
|
||||
std::chrono::high_resolution_clock::now().time_since_epoch());
|
||||
channel_->sendMediaSourceWithTimestampIndication(timestamp.count(), std::move(data), std::move(sendPromise));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads audio from a MediaSource (eg Microphone). Promise resolves to onMediaSourceDataReady.
|
||||
*/
|
||||
void MediaSourceService::readMediaSource() {
|
||||
OPENAUTO_LOG(debug) << "[MediaSourceService] readMediaSource()";
|
||||
if (audioInput_->isActive()) {
|
||||
auto readPromise = projection::IAudioInput::ReadPromise::defer(strand_);
|
||||
readPromise->then(
|
||||
std::bind(&MediaSourceService::onMediaSourceDataReady, this->shared_from_this(),
|
||||
std::placeholders::_1),
|
||||
[this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(debug) << "[MediaSourceService] audio input read rejected.";
|
||||
});
|
||||
|
||||
audioInput_->read(std::move(readPromise));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <aasdk/Channel/MediaSource/Audio/MicrophoneAudioChannel.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/MediaSource/MicrophoneMediaSourceService.hpp>
|
||||
|
||||
namespace f1x::openauto::autoapp::service::mediasource {
|
||||
MicrophoneMediaSourceService::MicrophoneMediaSourceService(boost::asio::io_service &ioService,
|
||||
aasdk::messenger::IMessenger::Pointer messenger,
|
||||
projection::IAudioInput::Pointer audioOutput)
|
||||
: MediaSourceService(ioService,
|
||||
std::make_shared<aasdk::channel::mediasource::audio::MicrophoneAudioChannel>(strand_,
|
||||
std::move(
|
||||
messenger)),
|
||||
std::move(audioOutput)) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
110
src/autoapp/Service/NavigationStatus/NavigationStatusService.cpp
Normal file
110
src/autoapp/Service/NavigationStatus/NavigationStatusService.cpp
Normal file
@ -0,0 +1,110 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <f1x/openauto/Common/Log.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/NavigationStatus/NavigationStatusService.hpp>
|
||||
#include <fstream>
|
||||
#include <QString>
|
||||
|
||||
namespace f1x::openauto::autoapp::service::navigationstatus {
|
||||
|
||||
NavigationStatusService::NavigationStatusService(boost::asio::io_service &ioService,
|
||||
aasdk::messenger::IMessenger::Pointer messenger)
|
||||
: strand_(ioService),
|
||||
timer_(ioService),
|
||||
channel_(std::make_shared<aasdk::channel::navigationstatus::NavigationStatusService>(strand_,
|
||||
std::move(messenger))) {
|
||||
|
||||
}
|
||||
|
||||
void NavigationStatusService::start() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[NavigationStatusService] start()";
|
||||
});
|
||||
}
|
||||
|
||||
void NavigationStatusService::stop() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[NavigationStatusService] stop()";
|
||||
});
|
||||
}
|
||||
|
||||
void NavigationStatusService::pause() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[NavigationStatusService] pause()";
|
||||
});
|
||||
}
|
||||
|
||||
void NavigationStatusService::resume() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[NavigationStatusService] resume()";
|
||||
});
|
||||
}
|
||||
|
||||
void NavigationStatusService::fillFeatures(
|
||||
aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) {
|
||||
OPENAUTO_LOG(info) << "[NavigationStatusService] fillFeatures()";
|
||||
|
||||
auto *service = response.add_channels();
|
||||
service->set_id(static_cast<uint32_t>(channel_->getId()));
|
||||
|
||||
auto *navigationStatus = service->mutable_navigation_status_service();
|
||||
}
|
||||
|
||||
void NavigationStatusService::onChannelOpenRequest(
|
||||
const aap_protobuf::service::control::message::ChannelOpenRequest &request) {
|
||||
OPENAUTO_LOG(info) << "[NavigationStatusService] onChannelOpenRequest()";
|
||||
OPENAUTO_LOG(info) << "[NavigationStatusService] Channel Id: " << request.service_id() << ", Priority: "
|
||||
<< request.priority();
|
||||
|
||||
aap_protobuf::service::control::message::ChannelOpenResponse response;
|
||||
const aap_protobuf::shared::MessageStatus status = aap_protobuf::shared::MessageStatus::STATUS_SUCCESS;
|
||||
response.set_status(status);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&NavigationStatusService::onChannelError, this->shared_from_this(),
|
||||
std::placeholders::_1));
|
||||
channel_->sendChannelOpenResponse(response, std::move(promise));
|
||||
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void NavigationStatusService::onStatusUpdate(
|
||||
const aap_protobuf::service::navigationstatus::message::NavigationStatus &navStatus) {
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
|
||||
void NavigationStatusService::onTurnEvent(
|
||||
const aap_protobuf::service::navigationstatus::message::NavigationNextTurnEvent &turnEvent) {
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void NavigationStatusService::onDistanceEvent(
|
||||
const aap_protobuf::service::navigationstatus::message::NavigationNextTurnDistanceEvent &distanceEvent) {
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
|
||||
void NavigationStatusService::onChannelError(const aasdk::error::Error &e) {
|
||||
OPENAUTO_LOG(error) << "[NavigationStatusService] onChannelError(): " << e.what();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
96
src/autoapp/Service/PhoneStatus/PhoneStatusService.cpp
Normal file
96
src/autoapp/Service/PhoneStatus/PhoneStatusService.cpp
Normal file
@ -0,0 +1,96 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <f1x/openauto/Common/Log.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/PhoneStatus/PhoneStatusService.hpp>
|
||||
#include <fstream>
|
||||
#include <QString>
|
||||
|
||||
namespace f1x {
|
||||
namespace openauto {
|
||||
namespace autoapp {
|
||||
namespace service {
|
||||
namespace phonestatus {
|
||||
|
||||
PhoneStatusService::PhoneStatusService(boost::asio::io_service &ioService,
|
||||
aasdk::messenger::IMessenger::Pointer messenger)
|
||||
: strand_(ioService),
|
||||
timer_(ioService),
|
||||
channel_(std::make_shared<aasdk::channel::phonestatus::PhoneStatusService>(strand_, std::move(messenger))) {
|
||||
|
||||
}
|
||||
|
||||
void PhoneStatusService::start() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[PhoneStatusService] start()";
|
||||
});
|
||||
}
|
||||
|
||||
void PhoneStatusService::stop() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[PhoneStatusService] stop()";
|
||||
});
|
||||
}
|
||||
|
||||
void PhoneStatusService::pause() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[PhoneStatusService] pause()";
|
||||
});
|
||||
}
|
||||
|
||||
void PhoneStatusService::resume() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[PhoneStatusService] resume()";
|
||||
});
|
||||
}
|
||||
|
||||
void PhoneStatusService::fillFeatures(
|
||||
aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) {
|
||||
OPENAUTO_LOG(info) << "[PhoneStatusService] fillFeatures()";
|
||||
|
||||
auto *service = response.add_channels();
|
||||
service->set_id(static_cast<uint32_t>(channel_->getId()));
|
||||
|
||||
auto *phoneStatus = service->mutable_phone_status_service();
|
||||
}
|
||||
|
||||
void PhoneStatusService::onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) {
|
||||
OPENAUTO_LOG(info) << "[PhoneStatusService] onChannelOpenRequest()";
|
||||
OPENAUTO_LOG(debug) << "[PhoneStatusService] Channel Id: " << request.service_id() << ", Priority: " << request.priority();
|
||||
|
||||
aap_protobuf::service::control::message::ChannelOpenResponse response;
|
||||
const aap_protobuf::shared::MessageStatus status = aap_protobuf::shared::MessageStatus::STATUS_SUCCESS;
|
||||
response.set_status(status);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&PhoneStatusService::onChannelError, this->shared_from_this(),
|
||||
std::placeholders::_1));
|
||||
channel_->sendChannelOpenResponse(response, std::move(promise));
|
||||
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
|
||||
void PhoneStatusService::onChannelError(const aasdk::error::Error &e) {
|
||||
OPENAUTO_LOG(error) << "[PhoneStatusService] onChannelError(): " << e.what();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -19,86 +19,60 @@
|
||||
#include <f1x/openauto/autoapp/Service/Pinger.hpp>
|
||||
#include <f1x/openauto/Common/Log.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace service
|
||||
{
|
||||
namespace f1x::openauto::autoapp::service {
|
||||
|
||||
Pinger::Pinger(boost::asio::io_service& ioService, time_t duration)
|
||||
: strand_(ioService)
|
||||
, timer_(ioService)
|
||||
, duration_(duration)
|
||||
, cancelled_(false)
|
||||
, pingsCount_(0)
|
||||
, pongsCount_(0)
|
||||
{
|
||||
Pinger::Pinger(boost::asio::io_service &ioService, time_t duration)
|
||||
: strand_(ioService), timer_(ioService), duration_(duration), cancelled_(false), pingsCount_(0), pongsCount_(0) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void Pinger::ping(Promise::Pointer promise)
|
||||
{
|
||||
void Pinger::ping(Promise::Pointer promise) {
|
||||
strand_.dispatch([this, self = this->shared_from_this(), promise = std::move(promise)]() mutable {
|
||||
cancelled_ = false;
|
||||
cancelled_ = false;
|
||||
|
||||
if(promise_ != nullptr)
|
||||
{
|
||||
promise_->reject(aasdk::error::Error(aasdk::error::ErrorCode::OPERATION_IN_PROGRESS));
|
||||
}
|
||||
else
|
||||
{
|
||||
++pingsCount_;
|
||||
OPENAUTO_LOG(info) << "[Pinger] Ping counter: " << pingsCount_;
|
||||
if (promise_ != nullptr) {
|
||||
promise_->reject(aasdk::error::Error(aasdk::error::ErrorCode::OPERATION_IN_PROGRESS));
|
||||
} else {
|
||||
++pingsCount_;
|
||||
OPENAUTO_LOG(debug) << "[Pinger] Ping counter: " << pingsCount_;
|
||||
|
||||
promise_ = std::move(promise);
|
||||
timer_.expires_from_now(boost::posix_time::milliseconds(duration_));
|
||||
timer_.async_wait(strand_.wrap(std::bind(&Pinger::onTimerExceeded, this->shared_from_this(), std::placeholders::_1)));
|
||||
}
|
||||
promise_ = std::move(promise);
|
||||
timer_.expires_from_now(boost::posix_time::milliseconds(duration_));
|
||||
timer_.async_wait(
|
||||
strand_.wrap(std::bind(&Pinger::onTimerExceeded, this->shared_from_this(), std::placeholders::_1)));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void Pinger::pong()
|
||||
{
|
||||
void Pinger::pong() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
++pongsCount_;
|
||||
OPENAUTO_LOG(info) << "[Pinger] Pong counter: " << pongsCount_;
|
||||
++pongsCount_;
|
||||
OPENAUTO_LOG(debug) << "[Pinger] Pong counter: " << pongsCount_;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void Pinger::onTimerExceeded(const boost::system::error_code& error)
|
||||
{
|
||||
if(promise_ == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if(error == boost::asio::error::operation_aborted || cancelled_)
|
||||
{
|
||||
promise_->reject(aasdk::error::Error(aasdk::error::ErrorCode::OPERATION_ABORTED));
|
||||
}
|
||||
else if(pingsCount_ - pongsCount_ > 4)
|
||||
{
|
||||
promise_->reject(aasdk::error::Error());
|
||||
}
|
||||
else
|
||||
{
|
||||
promise_->resolve();
|
||||
void Pinger::onTimerExceeded(const boost::system::error_code &error) {
|
||||
if (promise_ == nullptr) {
|
||||
return;
|
||||
} else if (error == boost::asio::error::operation_aborted || cancelled_) {
|
||||
promise_->reject(aasdk::error::Error(aasdk::error::ErrorCode::OPERATION_ABORTED));
|
||||
} else if (pingsCount_ - pongsCount_ > 4) {
|
||||
promise_->reject(aasdk::error::Error());
|
||||
} else {
|
||||
promise_->resolve();
|
||||
}
|
||||
|
||||
promise_.reset();
|
||||
}
|
||||
}
|
||||
|
||||
void Pinger::cancel()
|
||||
{
|
||||
void Pinger::cancel() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
cancelled_ = true;
|
||||
timer_.cancel();
|
||||
cancelled_ = true;
|
||||
timer_.cancel();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
94
src/autoapp/Service/Radio/RadioService.cpp
Normal file
94
src/autoapp/Service/Radio/RadioService.cpp
Normal file
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <f1x/openauto/Common/Log.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/Radio/RadioService.hpp>
|
||||
#include <fstream>
|
||||
#include <QString>
|
||||
|
||||
namespace f1x::openauto::autoapp::service::radio {
|
||||
|
||||
RadioService::RadioService(boost::asio::io_service &ioService,
|
||||
aasdk::messenger::IMessenger::Pointer messenger)
|
||||
: strand_(ioService),
|
||||
timer_(ioService),
|
||||
channel_(std::make_shared<aasdk::channel::radio::RadioService>(strand_, std::move(messenger))) {
|
||||
|
||||
}
|
||||
|
||||
void RadioService::start() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(debug) << "[RadioService] start()";
|
||||
});
|
||||
}
|
||||
|
||||
void RadioService::stop() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(debug) << "[RadioService] stop()";
|
||||
});
|
||||
}
|
||||
|
||||
void RadioService::pause() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(debug) << "[RadioService] pause()";
|
||||
});
|
||||
}
|
||||
|
||||
void RadioService::resume() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(debug) << "[RadioService] resume()";
|
||||
});
|
||||
}
|
||||
|
||||
void RadioService::fillFeatures(
|
||||
aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) {
|
||||
OPENAUTO_LOG(info) << "[RadioService] fillFeatures()";
|
||||
|
||||
auto *service = response.add_channels();
|
||||
service->set_id(static_cast<uint32_t>(channel_->getId()));
|
||||
|
||||
auto *radio = service->mutable_radio_service();
|
||||
}
|
||||
|
||||
void RadioService::onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) {
|
||||
OPENAUTO_LOG(info) << "[RadioService] onChannelOpenRequest()";
|
||||
OPENAUTO_LOG(debug) << "[RadioService] Channel Id: " << request.service_id() << ", Priority: "
|
||||
<< request.priority();
|
||||
|
||||
|
||||
aap_protobuf::service::control::message::ChannelOpenResponse response;
|
||||
const aap_protobuf::shared::MessageStatus status = aap_protobuf::shared::MessageStatus::STATUS_SUCCESS;
|
||||
response.set_status(status);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&RadioService::onChannelError, this->shared_from_this(),
|
||||
std::placeholders::_1));
|
||||
channel_->sendChannelOpenResponse(response, std::move(promise));
|
||||
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void RadioService::onChannelError(const aasdk::error::Error &e) {
|
||||
OPENAUTO_LOG(error) << "[RadioService] onChannelError(): " << e.what();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
259
src/autoapp/Service/Sensor/SensorService.cpp
Normal file
259
src/autoapp/Service/Sensor/SensorService.cpp
Normal file
@ -0,0 +1,259 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include <f1x/openauto/Common/Log.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/Sensor/SensorService.hpp>
|
||||
#include <fstream>
|
||||
#include <cmath>
|
||||
#include <gps.h>
|
||||
|
||||
namespace f1x::openauto::autoapp::service::sensor {
|
||||
SensorService::SensorService(boost::asio::io_service &ioService,
|
||||
aasdk::messenger::IMessenger::Pointer messenger)
|
||||
: strand_(ioService),
|
||||
timer_(ioService),
|
||||
channel_(std::make_shared<aasdk::channel::sensorsource::SensorSourceService>(strand_, std::move(messenger))) {
|
||||
|
||||
}
|
||||
|
||||
void SensorService::start() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
if (gps_open("127.0.0.1", "2947", &this->gpsData_)) {
|
||||
OPENAUTO_LOG(warning) << "[SensorService] can't connect to GPSD.";
|
||||
} else {
|
||||
OPENAUTO_LOG(info) << "[SensorService] Connected to GPSD.";
|
||||
gps_stream(&this->gpsData_, WATCH_ENABLE | WATCH_JSON, NULL);
|
||||
this->gpsEnabled_ = true;
|
||||
}
|
||||
|
||||
if (is_file_exist("/tmp/night_mode_enabled")) {
|
||||
this->isNight = true;
|
||||
}
|
||||
this->sensorPolling();
|
||||
|
||||
OPENAUTO_LOG(info) << "[SensorService] start()";
|
||||
channel_->receive(this->shared_from_this());
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
void SensorService::stop() {
|
||||
this->stopPolling = true;
|
||||
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
if (this->gpsEnabled_) {
|
||||
gps_stream(&this->gpsData_, WATCH_DISABLE, NULL);
|
||||
gps_close(&this->gpsData_);
|
||||
this->gpsEnabled_ = false;
|
||||
}
|
||||
|
||||
OPENAUTO_LOG(info) << "[SensorService] stop()";
|
||||
});
|
||||
}
|
||||
|
||||
void SensorService::pause() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[SensorService] pause()";
|
||||
});
|
||||
}
|
||||
|
||||
void SensorService::resume() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[SensorService] resume()";
|
||||
});
|
||||
}
|
||||
|
||||
void SensorService::fillFeatures(
|
||||
aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) {
|
||||
OPENAUTO_LOG(info) << "[SensorService] fillFeatures()";
|
||||
|
||||
auto *service = response.add_channels();
|
||||
service->set_id(static_cast<uint32_t>(channel_->getId()));
|
||||
|
||||
auto *sensorChannel = service->mutable_sensor_source_service();
|
||||
sensorChannel->add_sensors()->set_sensor_type(
|
||||
aap_protobuf::service::sensorsource::message::SensorType::SENSOR_DRIVING_STATUS_DATA);
|
||||
sensorChannel->add_sensors()->set_sensor_type(
|
||||
aap_protobuf::service::sensorsource::message::SensorType::SENSOR_LOCATION);
|
||||
sensorChannel->add_sensors()->set_sensor_type(
|
||||
aap_protobuf::service::sensorsource::message::SensorType::SENSOR_NIGHT_MODE);
|
||||
}
|
||||
|
||||
void SensorService::onChannelOpenRequest(const aap_protobuf::service::control::message::ChannelOpenRequest &request) {
|
||||
OPENAUTO_LOG(info) << "[SensorService] onChannelOpenRequest()";
|
||||
OPENAUTO_LOG(debug) << "[SensorService] Channel Id: " << request.service_id() << ", Priority: "
|
||||
<< request.priority();
|
||||
|
||||
aap_protobuf::service::control::message::ChannelOpenResponse response;
|
||||
const aap_protobuf::shared::MessageStatus status = aap_protobuf::shared::MessageStatus::STATUS_SUCCESS;
|
||||
response.set_status(status);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {},
|
||||
std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
channel_->sendChannelOpenResponse(response, std::move(promise));
|
||||
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void SensorService::onSensorStartRequest(
|
||||
const aap_protobuf::service::sensorsource::message::SensorRequest &request) {
|
||||
OPENAUTO_LOG(info) << "[SensorService] onSensorStartRequest()";
|
||||
OPENAUTO_LOG(debug) << "[SensorService] Request Type: " << request.type();
|
||||
|
||||
aap_protobuf::service::sensorsource::message::SensorStartResponseMessage response;
|
||||
response.set_status(aap_protobuf::shared::MessageStatus::STATUS_SUCCESS);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
|
||||
if (request.type() == aap_protobuf::service::sensorsource::message::SENSOR_DRIVING_STATUS_DATA) {
|
||||
promise->then(std::bind(&SensorService::sendDrivingStatusUnrestricted, this->shared_from_this()),
|
||||
std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
} else if (request.type() == aap_protobuf::service::sensorsource::message::SensorType::SENSOR_NIGHT_MODE) {
|
||||
promise->then(std::bind(&SensorService::sendNightData, this->shared_from_this()),
|
||||
std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
} else {
|
||||
promise->then([]() {},
|
||||
std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
}
|
||||
|
||||
channel_->sendSensorStartResponse(response, std::move(promise));
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void SensorService::sendDrivingStatusUnrestricted() {
|
||||
OPENAUTO_LOG(info) << "[SensorService] sendDrivingStatusUnrestricted()";
|
||||
aap_protobuf::service::sensorsource::message::SensorBatch indication;
|
||||
indication.add_driving_status_data()->set_status(
|
||||
aap_protobuf::service::sensorsource::message::DrivingStatus::DRIVE_STATUS_UNRESTRICTED);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {},
|
||||
std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
channel_->sendSensorEventIndication(indication, std::move(promise));
|
||||
}
|
||||
|
||||
void SensorService::sendNightData() {
|
||||
OPENAUTO_LOG(info) << "[SensorService] sendNightData()";
|
||||
aap_protobuf::service::sensorsource::message::SensorBatch indication;
|
||||
|
||||
if (SensorService::isNight) {
|
||||
OPENAUTO_LOG(info) << "[SensorService] Night Mode Triggered";
|
||||
indication.add_night_mode_data()->set_night_mode(true);
|
||||
} else {
|
||||
OPENAUTO_LOG(info) << "[SensorService] Day Mode Triggered";
|
||||
indication.add_night_mode_data()->set_night_mode(false);
|
||||
}
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {},
|
||||
std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
channel_->sendSensorEventIndication(indication, std::move(promise));
|
||||
if (this->firstRun) {
|
||||
this->firstRun = false;
|
||||
this->previous = this->isNight;
|
||||
}
|
||||
}
|
||||
|
||||
void SensorService::sendGPSLocationData() {
|
||||
OPENAUTO_LOG(info) << "[SensorService] sendGPSLocationData()";
|
||||
aap_protobuf::service::sensorsource::message::SensorBatch indication;
|
||||
|
||||
auto *locInd = indication.add_location_data();
|
||||
|
||||
// epoch seconds
|
||||
#if GPSD_API_MAJOR_VERSION >= 7
|
||||
locInd->set_timestamp(this->gpsData_.fix.time.tv_sec);
|
||||
#else
|
||||
locInd->set_timestamp(this->gpsData_.fix.time);
|
||||
#endif
|
||||
// degrees
|
||||
locInd->set_latitude_e7(this->gpsData_.fix.latitude * 1e7);
|
||||
locInd->set_longitude_e7(this->gpsData_.fix.longitude * 1e7);
|
||||
// meters
|
||||
auto accuracy = sqrt(pow(this->gpsData_.fix.epx, 2) + pow(this->gpsData_.fix.epy, 2));
|
||||
locInd->set_accuracy_e3(accuracy * 1e3);
|
||||
|
||||
if (this->gpsData_.set & ALTITUDE_SET) {
|
||||
// meters above ellipsoid
|
||||
locInd->set_altitude_e2(this->gpsData_.fix.altitude * 1e2);
|
||||
}
|
||||
if (this->gpsData_.set & SPEED_SET) {
|
||||
// meters per second to knots
|
||||
locInd->set_speed_e3(this->gpsData_.fix.speed * 1.94384 * 1e3);
|
||||
}
|
||||
if (this->gpsData_.set & TRACK_SET) {
|
||||
// degrees
|
||||
locInd->set_bearing_e6(this->gpsData_.fix.track * 1e6);
|
||||
}
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {},
|
||||
std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
channel_->sendSensorEventIndication(indication, std::move(promise));
|
||||
}
|
||||
|
||||
void SensorService::sensorPolling() {
|
||||
OPENAUTO_LOG(info) << "[SensorService] sensorPolling()";
|
||||
if (!this->stopPolling) {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
this->isNight = is_file_exist("/tmp/night_mode_enabled");
|
||||
if (this->previous != this->isNight && !this->firstRun) {
|
||||
this->previous = this->isNight;
|
||||
this->sendNightData();
|
||||
}
|
||||
bool gpsDataAvailable = false;
|
||||
#if GPSD_API_MAJOR_VERSION >= 7
|
||||
if (gps_read (&this->gpsData_, NULL, 0) != -1) {
|
||||
gpsDataAvailable = true;
|
||||
}
|
||||
#else
|
||||
if (gps_read (&this->gpsData_) != -1) {
|
||||
gpsDataAvailable = true;
|
||||
}
|
||||
#endif
|
||||
if ((this->gpsEnabled_) &&
|
||||
(gps_waiting(&this->gpsData_, 0)) &&
|
||||
(gpsDataAvailable == true) &&
|
||||
(this->gpsData_.fix.mode == MODE_2D || this->gpsData_.fix.mode == MODE_3D) &&
|
||||
(this->gpsData_.set & TIME_SET) &&
|
||||
(this->gpsData_.set & LATLON_SET))
|
||||
{
|
||||
this->sendGPSLocationData();
|
||||
}
|
||||
|
||||
timer_.expires_from_now(boost::posix_time::milliseconds(250));
|
||||
timer_.async_wait(strand_.wrap(std::bind(&SensorService::sensorPolling, this->shared_from_this())));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
bool SensorService::is_file_exist(const char *fileName) {
|
||||
OPENAUTO_LOG(info) << "[SensorService] is_file_exist()";
|
||||
std::ifstream ifile(fileName, std::ios::in);
|
||||
return ifile.good();
|
||||
}
|
||||
|
||||
void SensorService::onChannelError(const aasdk::error::Error &e) {
|
||||
OPENAUTO_LOG(error) << "[SensorService] onChannelError(): " << e.what();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,273 +0,0 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <aasdk_proto/DrivingStatusEnum.pb.h>
|
||||
#include <f1x/openauto/Common/Log.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/SensorService.hpp>
|
||||
#include <fstream>
|
||||
#include <cmath>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace service
|
||||
{
|
||||
|
||||
SensorService::SensorService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger)
|
||||
: strand_(ioService),
|
||||
timer_(ioService),
|
||||
channel_(std::make_shared<aasdk::channel::sensor::SensorServiceChannel>(strand_, std::move(messenger)))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SensorService::start()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
if (gps_open("127.0.0.1", "2947", &this->gpsData_))
|
||||
{
|
||||
OPENAUTO_LOG(warning) << "[SensorService] can't connect to GPSD.";
|
||||
}
|
||||
else
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[SensorService] Connected to GPSD.";
|
||||
gps_stream(&this->gpsData_, WATCH_ENABLE | WATCH_JSON, NULL);
|
||||
this->gpsEnabled_ = true;
|
||||
}
|
||||
|
||||
if (is_file_exist("/tmp/night_mode_enabled")) {
|
||||
this->isNight = true;
|
||||
}
|
||||
this->sensorPolling();
|
||||
|
||||
OPENAUTO_LOG(info) << "[SensorService] start.";
|
||||
channel_->receive(this->shared_from_this());
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
void SensorService::stop()
|
||||
{
|
||||
this->stopPolling = true;
|
||||
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
if (this->gpsEnabled_)
|
||||
{
|
||||
gps_stream(&this->gpsData_, WATCH_DISABLE, NULL);
|
||||
gps_close(&this->gpsData_);
|
||||
this->gpsEnabled_ = false;
|
||||
}
|
||||
|
||||
OPENAUTO_LOG(info) << "[SensorService] stop.";
|
||||
});
|
||||
}
|
||||
|
||||
void SensorService::pause()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[SensorService] pause.";
|
||||
});
|
||||
}
|
||||
|
||||
void SensorService::resume()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[SensorService] resume.";
|
||||
});
|
||||
}
|
||||
|
||||
void SensorService::fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[SensorService] fill features.";
|
||||
|
||||
auto* channelDescriptor = response.add_channels();
|
||||
channelDescriptor->set_channel_id(static_cast<uint32_t>(channel_->getId()));
|
||||
|
||||
auto* sensorChannel = channelDescriptor->mutable_sensor_channel();
|
||||
sensorChannel->add_sensors()->set_type(aasdk::proto::enums::SensorType::DRIVING_STATUS);
|
||||
sensorChannel->add_sensors()->set_type(aasdk::proto::enums::SensorType::LOCATION);
|
||||
sensorChannel->add_sensors()->set_type(aasdk::proto::enums::SensorType::NIGHT_DATA);
|
||||
}
|
||||
|
||||
void SensorService::onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[SensorService] open request, priority: " << request.priority();
|
||||
const aasdk::proto::enums::Status::Enum status = aasdk::proto::enums::Status::OK;
|
||||
OPENAUTO_LOG(info) << "[SensorService] open status: " << status;
|
||||
|
||||
aasdk::proto::messages::ChannelOpenResponse response;
|
||||
response.set_status(status);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
channel_->sendChannelOpenResponse(response, std::move(promise));
|
||||
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void SensorService::onSensorStartRequest(const aasdk::proto::messages::SensorStartRequestMessage& request)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[SensorService] sensor start request, type: " << request.sensor_type();
|
||||
|
||||
aasdk::proto::messages::SensorStartResponseMessage response;
|
||||
response.set_status(aasdk::proto::enums::Status::OK);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
|
||||
if(request.sensor_type() == aasdk::proto::enums::SensorType::DRIVING_STATUS)
|
||||
{
|
||||
promise->then(std::bind(&SensorService::sendDrivingStatusUnrestricted, this->shared_from_this()),
|
||||
std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
}
|
||||
else if(request.sensor_type() == aasdk::proto::enums::SensorType::NIGHT_DATA)
|
||||
{
|
||||
promise->then(std::bind(&SensorService::sendNightData, this->shared_from_this()),
|
||||
std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
}
|
||||
else
|
||||
{
|
||||
promise->then([]() {}, std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
}
|
||||
|
||||
channel_->sendSensorStartResponse(response, std::move(promise));
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void SensorService::sendDrivingStatusUnrestricted()
|
||||
{
|
||||
aasdk::proto::messages::SensorEventIndication indication;
|
||||
indication.add_driving_status()->set_status(aasdk::proto::enums::DrivingStatus::UNRESTRICTED);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
channel_->sendSensorEventIndication(indication, std::move(promise));
|
||||
}
|
||||
|
||||
void SensorService::sendNightData()
|
||||
{
|
||||
aasdk::proto::messages::SensorEventIndication indication;
|
||||
|
||||
if (SensorService::isNight) {
|
||||
OPENAUTO_LOG(info) << "[SensorService] Mode night triggered";
|
||||
indication.add_night_mode()->set_is_night(true);
|
||||
} else {
|
||||
OPENAUTO_LOG(info) << "[SensorService] Mode day triggered";
|
||||
indication.add_night_mode()->set_is_night(false);
|
||||
}
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
channel_->sendSensorEventIndication(indication, std::move(promise));
|
||||
if (this->firstRun) {
|
||||
this->firstRun = false;
|
||||
this->previous = this->isNight;
|
||||
}
|
||||
}
|
||||
|
||||
void SensorService::sendGPSLocationData()
|
||||
{
|
||||
aasdk::proto::messages::SensorEventIndication indication;
|
||||
auto * locInd = indication.add_gps_location();
|
||||
|
||||
// epoch seconds
|
||||
#if GPSD_API_MAJOR_VERSION >= 7
|
||||
locInd->set_timestamp(this->gpsData_.fix.time.tv_sec);
|
||||
#else
|
||||
locInd->set_timestamp(this->gpsData_.fix.time);
|
||||
#endif
|
||||
// degrees
|
||||
locInd->set_latitude(this->gpsData_.fix.latitude * 1e7);
|
||||
locInd->set_longitude(this->gpsData_.fix.longitude * 1e7);
|
||||
// meters
|
||||
auto accuracy = sqrt(pow(this->gpsData_.fix.epx, 2) + pow(this->gpsData_.fix.epy, 2));
|
||||
locInd->set_accuracy(accuracy * 1e3);
|
||||
|
||||
if (this->gpsData_.set & ALTITUDE_SET)
|
||||
{
|
||||
// meters above ellipsoid
|
||||
locInd->set_altitude(this->gpsData_.fix.altitude * 1e2);
|
||||
}
|
||||
if (this->gpsData_.set & SPEED_SET)
|
||||
{
|
||||
// meters per second to knots
|
||||
locInd->set_speed(this->gpsData_.fix.speed * 1.94384 * 1e3);
|
||||
}
|
||||
if (this->gpsData_.set & TRACK_SET)
|
||||
{
|
||||
// degrees
|
||||
locInd->set_bearing(this->gpsData_.fix.track * 1e6);
|
||||
}
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&SensorService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
channel_->sendSensorEventIndication(indication, std::move(promise));
|
||||
}
|
||||
|
||||
void SensorService::sensorPolling()
|
||||
{
|
||||
if (!this->stopPolling) {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
this->isNight = is_file_exist("/tmp/night_mode_enabled");
|
||||
if (this->previous != this->isNight && !this->firstRun) {
|
||||
this->previous = this->isNight;
|
||||
this->sendNightData();
|
||||
}
|
||||
bool gpsDataAvailable = false;
|
||||
#if GPSD_API_MAJOR_VERSION >= 7
|
||||
if (gps_read (&this->gpsData_, NULL, 0) != -1) {
|
||||
gpsDataAvailable = true;
|
||||
}
|
||||
#else
|
||||
if (gps_read (&this->gpsData_) != -1) {
|
||||
gpsDataAvailable = true;
|
||||
}
|
||||
#endif
|
||||
if ((this->gpsEnabled_) &&
|
||||
(gps_waiting(&this->gpsData_, 0)) &&
|
||||
(gpsDataAvailable == true) &&
|
||||
(this->gpsData_.fix.mode == MODE_2D || this->gpsData_.fix.mode == MODE_3D) &&
|
||||
(this->gpsData_.set & TIME_SET) &&
|
||||
(this->gpsData_.set & LATLON_SET))
|
||||
{
|
||||
this->sendGPSLocationData();
|
||||
}
|
||||
|
||||
timer_.expires_from_now(boost::posix_time::milliseconds(250));
|
||||
timer_.async_wait(strand_.wrap(std::bind(&SensorService::sensorPolling, this->shared_from_this())));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
bool SensorService::is_file_exist(const char *fileName)
|
||||
{
|
||||
std::ifstream ifile(fileName, std::ios::in);
|
||||
return ifile.good();
|
||||
}
|
||||
|
||||
void SensorService::onChannelError(const aasdk::error::Error& e)
|
||||
{
|
||||
OPENAUTO_LOG(error) << "[SensorService] channel error: " << e.what();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -18,18 +18,26 @@
|
||||
|
||||
#include <QApplication>
|
||||
#include <QScreen>
|
||||
#include <aasdk/Channel/AV/MediaAudioServiceChannel.hpp>
|
||||
#include <aasdk/Channel/AV/SystemAudioServiceChannel.hpp>
|
||||
#include <aasdk/Channel/AV/SpeechAudioServiceChannel.hpp>
|
||||
|
||||
#include <aasdk/Channel/MediaSink/Audio/Channel/MediaAudioChannel.hpp>
|
||||
#include <aasdk/Channel/MediaSink/Audio/Channel/SystemAudioChannel.hpp>
|
||||
#include <aasdk/Channel/MediaSink/Audio/Channel/GuidanceAudioChannel.hpp>
|
||||
#include <aasdk/Channel/MediaSink/Audio/Channel/TelephonyAudioChannel.hpp>
|
||||
|
||||
#include <f1x/openauto/autoapp/Service/ServiceFactory.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/VideoService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/MediaAudioService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/SpeechAudioService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/SystemAudioService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/AudioInputService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/SensorService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/BluetoothService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/InputService.hpp>
|
||||
|
||||
#include <f1x/openauto/autoapp/Service/MediaSink/VideoService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/MediaSink/MediaAudioService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/MediaSink/GuidanceAudioService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/MediaSink/SystemAudioService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/MediaSink/TelephonyAudioService.hpp>
|
||||
|
||||
#include <f1x/openauto/autoapp/Service/MediaSource/MicrophoneMediaSourceService.hpp>
|
||||
|
||||
#include <f1x/openauto/autoapp/Service/Sensor/SensorService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/Bluetooth/BluetoothService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/InputSource/InputSourceService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/WifiProjection/WifiProjectionService.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/QtVideoOutput.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/OMXVideoOutput.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/RtAudioOutput.hpp>
|
||||
@ -37,129 +45,169 @@
|
||||
#include <f1x/openauto/autoapp/Projection/QtAudioInput.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/InputDevice.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/LocalBluetoothDevice.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/RemoteBluetoothDevice.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/DummyBluetoothDevice.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/WifiService.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace service
|
||||
{
|
||||
namespace f1x::openauto::autoapp::service {
|
||||
|
||||
ServiceFactory::ServiceFactory(boost::asio::io_service& ioService, configuration::IConfiguration::Pointer configuration)
|
||||
: ioService_(ioService)
|
||||
, configuration_(std::move(configuration))
|
||||
{
|
||||
ServiceFactory::ServiceFactory(boost::asio::io_service &ioService,
|
||||
configuration::IConfiguration::Pointer configuration)
|
||||
: ioService_(ioService), configuration_(std::move(configuration)) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
ServiceList ServiceFactory::create(aasdk::messenger::IMessenger::Pointer messenger)
|
||||
{
|
||||
ServiceList ServiceFactory::create(aasdk::messenger::IMessenger::Pointer messenger) {
|
||||
OPENAUTO_LOG(info) << "[ServiceFactory] create()";
|
||||
ServiceList serviceList;
|
||||
|
||||
projection::IAudioInput::Pointer audioInput(new projection::QtAudioInput(1, 16, 16000), std::bind(&QObject::deleteLater, std::placeholders::_1));
|
||||
serviceList.emplace_back(std::make_shared<AudioInputService>(ioService_, messenger, std::move(audioInput)));
|
||||
this->createAudioServices(serviceList, messenger);
|
||||
serviceList.emplace_back(std::make_shared<SensorService>(ioService_, messenger));
|
||||
serviceList.emplace_back(this->createVideoService(messenger));
|
||||
this->createMediaSinkServices(serviceList, messenger);
|
||||
this->createMediaSourceServices(serviceList, messenger);
|
||||
serviceList.emplace_back(this->createSensorService(messenger));
|
||||
serviceList.emplace_back(this->createInputService(messenger));
|
||||
if (configuration_->getWirelessProjectionEnabled())
|
||||
{
|
||||
// TODO: What is WiFi Projection Service?
|
||||
/*
|
||||
* The btservice seems to handle connecting over bluetooth and allow AA to establish a WiFi connection for Projection
|
||||
* If WifiProjection is a legitimate service, then it seems clear it is not what we think it actually is.
|
||||
*/
|
||||
serviceList.emplace_back(this->createBluetoothService(messenger));
|
||||
serviceList.emplace_back(std::make_shared<WifiService>(ioService_, messenger, configuration_));
|
||||
// serviceList.emplace_back(this->createWifiProjectionService(messenger));
|
||||
}
|
||||
serviceList.emplace_back(this->createInputService(messenger));
|
||||
|
||||
return serviceList;
|
||||
}
|
||||
}
|
||||
|
||||
IService::Pointer ServiceFactory::createVideoService(aasdk::messenger::IMessenger::Pointer messenger)
|
||||
{
|
||||
#ifdef USE_OMX
|
||||
auto videoOutput(std::make_shared<projection::OMXVideoOutput>(configuration_));
|
||||
#else
|
||||
projection::IVideoOutput::Pointer videoOutput(new projection::QtVideoOutput(configuration_), std::bind(&QObject::deleteLater, std::placeholders::_1));
|
||||
#endif
|
||||
return std::make_shared<VideoService>(ioService_, messenger, std::move(videoOutput));
|
||||
}
|
||||
|
||||
IService::Pointer ServiceFactory::createBluetoothService(aasdk::messenger::IMessenger::Pointer messenger)
|
||||
{
|
||||
IService::Pointer ServiceFactory::createBluetoothService(aasdk::messenger::IMessenger::Pointer messenger) {
|
||||
OPENAUTO_LOG(info) << "[ServiceFactory] createBluetoothService()";
|
||||
projection::IBluetoothDevice::Pointer bluetoothDevice;
|
||||
switch(configuration_->getBluetoothAdapterType())
|
||||
{
|
||||
case configuration::BluetoothAdapterType::LOCAL:
|
||||
bluetoothDevice = projection::IBluetoothDevice::Pointer(new projection::LocalBluetoothDevice(), std::bind(&QObject::deleteLater, std::placeholders::_1));
|
||||
break;
|
||||
|
||||
case configuration::BluetoothAdapterType::REMOTE:
|
||||
bluetoothDevice = std::make_shared<projection::RemoteBluetoothDevice>(configuration_->getBluetoothRemoteAdapterAddress());
|
||||
break;
|
||||
|
||||
default:
|
||||
bluetoothDevice = std::make_shared<projection::DummyBluetoothDevice>();
|
||||
break;
|
||||
if (configuration_->getBluetoothAdapterAddress() == "") {
|
||||
OPENAUTO_LOG(debug) << "[ServiceFactory] Using Dummy Bluetooth";
|
||||
bluetoothDevice = std::make_shared<projection::DummyBluetoothDevice>();
|
||||
} else {
|
||||
OPENAUTO_LOG(info) << "[ServiceFactory] Using Local Bluetooth Adapter";
|
||||
bluetoothDevice = projection::IBluetoothDevice::Pointer(new projection::LocalBluetoothDevice(),
|
||||
std::bind(&QObject::deleteLater,
|
||||
std::placeholders::_1));
|
||||
}
|
||||
|
||||
return std::make_shared<BluetoothService>(ioService_, messenger, std::move(bluetoothDevice));
|
||||
}
|
||||
return std::make_shared<bluetooth::BluetoothService>(ioService_, messenger, std::move(bluetoothDevice));
|
||||
}
|
||||
|
||||
IService::Pointer ServiceFactory::createInputService(aasdk::messenger::IMessenger::Pointer messenger)
|
||||
{
|
||||
IService::Pointer ServiceFactory::createInputService(aasdk::messenger::IMessenger::Pointer messenger) {
|
||||
OPENAUTO_LOG(info) << "[ServiceFactory] createInputService()";
|
||||
QRect videoGeometry;
|
||||
switch(configuration_->getVideoResolution())
|
||||
{
|
||||
case aasdk::proto::enums::VideoResolution::_720p:
|
||||
switch (configuration_->getVideoResolution()) {
|
||||
case aap_protobuf::service::media::sink::message::VideoCodecResolutionType::VIDEO_1280x720:
|
||||
OPENAUTO_LOG(info) << "[ServiceFactory] Resolution 1280x720";
|
||||
videoGeometry = QRect(0, 0, 1280, 720);
|
||||
break;
|
||||
|
||||
case aasdk::proto::enums::VideoResolution::_1080p:
|
||||
case aap_protobuf::service::media::sink::message::VideoCodecResolutionType::VIDEO_1920x1080:
|
||||
OPENAUTO_LOG(info) << "[ServiceFactory] Resolution 1920x1080";
|
||||
videoGeometry = QRect(0, 0, 1920, 1080);
|
||||
break;
|
||||
|
||||
default:
|
||||
default:
|
||||
OPENAUTO_LOG(info) << "[ServiceFactory] Resolution 800x480";
|
||||
videoGeometry = QRect(0, 0, 800, 480);
|
||||
break;
|
||||
}
|
||||
|
||||
QScreen* screen = QGuiApplication::primaryScreen();
|
||||
QScreen *screen = QGuiApplication::primaryScreen();
|
||||
QRect screenGeometry = screen == nullptr ? QRect(0, 0, 1, 1) : screen->geometry();
|
||||
projection::IInputDevice::Pointer inputDevice(std::make_shared<projection::InputDevice>(*QApplication::instance(), configuration_, std::move(screenGeometry), std::move(videoGeometry)));
|
||||
projection::IInputDevice::Pointer inputDevice(
|
||||
std::make_shared<projection::InputDevice>(*QApplication::instance(), configuration_,
|
||||
std::move(screenGeometry), std::move(videoGeometry)));
|
||||
|
||||
return std::make_shared<InputService>(ioService_, messenger, std::move(inputDevice));
|
||||
}
|
||||
return std::make_shared<inputsource::InputSourceService>(ioService_, messenger, std::move(inputDevice));
|
||||
}
|
||||
|
||||
void ServiceFactory::createAudioServices(ServiceList& serviceList, aasdk::messenger::IMessenger::Pointer messenger)
|
||||
{
|
||||
if(configuration_->musicAudioChannelEnabled())
|
||||
{
|
||||
auto mediaAudioOutput = configuration_->getAudioOutputBackendType() == configuration::AudioOutputBackendType::RTAUDIO ?
|
||||
std::make_shared<projection::RtAudioOutput>(2, 16, 48000) :
|
||||
projection::IAudioOutput::Pointer(new projection::QtAudioOutput(2, 16, 48000), std::bind(&QObject::deleteLater, std::placeholders::_1));
|
||||
void ServiceFactory::createMediaSinkServices(ServiceList &serviceList,
|
||||
aasdk::messenger::IMessenger::Pointer messenger) {
|
||||
OPENAUTO_LOG(info) << "[ServiceFactory] createMediaSinkServices()";
|
||||
if (configuration_->musicAudioChannelEnabled()) {
|
||||
OPENAUTO_LOG(info) << "[ServiceFactory] Media Audio Channel enabled";
|
||||
auto mediaAudioOutput =
|
||||
configuration_->getAudioOutputBackendType() == configuration::AudioOutputBackendType::RTAUDIO ?
|
||||
std::make_shared<projection::RtAudioOutput>(2, 16, 48000) :
|
||||
projection::IAudioOutput::Pointer(new projection::QtAudioOutput(2, 16, 48000),
|
||||
std::bind(&QObject::deleteLater, std::placeholders::_1));
|
||||
|
||||
serviceList.emplace_back(std::make_shared<MediaAudioService>(ioService_, messenger, std::move(mediaAudioOutput)));
|
||||
serviceList.emplace_back(
|
||||
std::make_shared<mediasink::MediaAudioService>(ioService_, messenger, std::move(mediaAudioOutput)));
|
||||
}
|
||||
|
||||
if(configuration_->speechAudioChannelEnabled())
|
||||
{
|
||||
auto speechAudioOutput = configuration_->getAudioOutputBackendType() == configuration::AudioOutputBackendType::RTAUDIO ?
|
||||
std::make_shared<projection::RtAudioOutput>(1, 16, 16000) :
|
||||
projection::IAudioOutput::Pointer(new projection::QtAudioOutput(1, 16, 16000), std::bind(&QObject::deleteLater, std::placeholders::_1));
|
||||
if (configuration_->guidanceAudioChannelEnabled()) {
|
||||
OPENAUTO_LOG(info) << "[ServiceFactory] Guidance Audio Channel enabled";
|
||||
auto guidanceAudioOutput =
|
||||
configuration_->getAudioOutputBackendType() == configuration::AudioOutputBackendType::RTAUDIO ?
|
||||
std::make_shared<projection::RtAudioOutput>(1, 16, 16000) :
|
||||
projection::IAudioOutput::Pointer(new projection::QtAudioOutput(1, 16, 16000),
|
||||
std::bind(&QObject::deleteLater, std::placeholders::_1));
|
||||
|
||||
serviceList.emplace_back(std::make_shared<SpeechAudioService>(ioService_, messenger, std::move(speechAudioOutput)));
|
||||
serviceList.emplace_back(
|
||||
std::make_shared<mediasink::GuidanceAudioService>(ioService_, messenger,
|
||||
std::move(guidanceAudioOutput)));
|
||||
}
|
||||
|
||||
auto systemAudioOutput = configuration_->getAudioOutputBackendType() == configuration::AudioOutputBackendType::RTAUDIO ?
|
||||
std::make_shared<projection::RtAudioOutput>(1, 16, 16000) :
|
||||
projection::IAudioOutput::Pointer(new projection::QtAudioOutput(1, 16, 16000), std::bind(&QObject::deleteLater, std::placeholders::_1));
|
||||
/* TODO: This also causes a problem - suspect not actually enabled yet in AA, or removed due to preference of Bluetooth.
|
||||
if (configuration_->telephonyAudioChannelEnabled()) {
|
||||
OPENAUTO_LOG(info) << "[ServiceFactory] Telephony Audio Channel enabled";
|
||||
auto telephonyAudioOutput =
|
||||
configuration_->getAudioOutputBackendType() == configuration::AudioOutputBackendType::RTAUDIO ?
|
||||
std::make_shared<projection::RtAudioOutput>(1, 16, 16000) :
|
||||
projection::IAudioOutput::Pointer(new projection::QtAudioOutput(1, 16, 16000),
|
||||
std::bind(&QObject::deleteLater, std::placeholders::_1));
|
||||
|
||||
serviceList.emplace_back(std::make_shared<SystemAudioService>(ioService_, messenger, std::move(systemAudioOutput)));
|
||||
}
|
||||
serviceList.emplace_back(
|
||||
std::make_shared<mediasink::TelephonyAudioService>(ioService_, messenger,
|
||||
std::move(telephonyAudioOutput)));
|
||||
}
|
||||
*/
|
||||
/*
|
||||
* No Need to Check for systemAudioChannelEnabled - MUST be enabled by default.
|
||||
*/
|
||||
|
||||
OPENAUTO_LOG(info) << "[ServiceFactory] System Audio Channel enabled";
|
||||
auto systemAudioOutput =
|
||||
configuration_->getAudioOutputBackendType() == configuration::AudioOutputBackendType::RTAUDIO ?
|
||||
std::make_shared<projection::RtAudioOutput>(1, 16, 16000) :
|
||||
projection::IAudioOutput::Pointer(new projection::QtAudioOutput(1, 16, 16000),
|
||||
std::bind(&QObject::deleteLater, std::placeholders::_1));
|
||||
|
||||
serviceList.emplace_back(
|
||||
std::make_shared<mediasink::SystemAudioService>(ioService_, messenger, std::move(systemAudioOutput)));
|
||||
|
||||
#ifdef USE_OMX
|
||||
auto videoOutput(std::make_shared<projection::OMXVideoOutput>(configuration_));
|
||||
#else
|
||||
projection::IVideoOutput::Pointer videoOutput(new projection::QtVideoOutput(configuration_),
|
||||
std::bind(&QObject::deleteLater, std::placeholders::_1));
|
||||
#endif
|
||||
|
||||
OPENAUTO_LOG(info) << "[ServiceFactory] Video Channel enabled";
|
||||
serviceList.emplace_back(
|
||||
std::make_shared<mediasink::VideoService>(ioService_, messenger, std::move(videoOutput)));
|
||||
}
|
||||
|
||||
void ServiceFactory::createMediaSourceServices(f1x::openauto::autoapp::service::ServiceList &serviceList,
|
||||
aasdk::messenger::IMessenger::Pointer messenger) {
|
||||
OPENAUTO_LOG(info) << "[ServiceFactory] createMediaSourceServices()";
|
||||
projection::IAudioInput::Pointer audioInput(new projection::QtAudioInput(1, 16, 16000),
|
||||
std::bind(&QObject::deleteLater, std::placeholders::_1));
|
||||
serviceList.emplace_back(std::make_shared<mediasource::MicrophoneMediaSourceService>(ioService_, messenger,
|
||||
std::move(audioInput)));
|
||||
}
|
||||
|
||||
IService::Pointer ServiceFactory::createSensorService(aasdk::messenger::IMessenger::Pointer messenger) {
|
||||
OPENAUTO_LOG(info) << "[ServiceFactory] createSensorService()";
|
||||
return std::make_shared<sensor::SensorService>(ioService_, messenger);
|
||||
}
|
||||
|
||||
IService::Pointer ServiceFactory::createWifiProjectionService(aasdk::messenger::IMessenger::Pointer messenger) {
|
||||
OPENAUTO_LOG(info) << "[ServiceFactory] createWifiProjectionService()";
|
||||
return std::make_shared<wifiprojection::WifiProjectionService>(ioService_, messenger, configuration_);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <aasdk/Channel/AV/SpeechAudioServiceChannel.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/SpeechAudioService.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace service
|
||||
{
|
||||
|
||||
SpeechAudioService::SpeechAudioService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IAudioOutput::Pointer audioOutput)
|
||||
: AudioService(ioService, std::make_shared<aasdk::channel::av::SpeechAudioServiceChannel>(strand_, std::move(messenger)), std::move(audioOutput))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <aasdk/Channel/AV/SystemAudioServiceChannel.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/SystemAudioService.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace service
|
||||
{
|
||||
|
||||
SystemAudioService::SystemAudioService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IAudioOutput::Pointer audioOutput)
|
||||
: AudioService(ioService, std::make_shared<aasdk::channel::av::SystemAudioServiceChannel>(strand_, std::move(messenger)), std::move(audioOutput))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <f1x/openauto/Common/Log.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/VendorExtension/VendorExtensionService.hpp>
|
||||
#include <fstream>
|
||||
#include <QString>
|
||||
|
||||
namespace f1x::openauto::autoapp::service::vendorextension {
|
||||
|
||||
VendorExtensionService::VendorExtensionService(boost::asio::io_service &ioService,
|
||||
aasdk::messenger::IMessenger::Pointer messenger)
|
||||
: strand_(ioService),
|
||||
timer_(ioService),
|
||||
channel_(
|
||||
std::make_shared<aasdk::channel::vendorextension::VendorExtensionService>(strand_, std::move(messenger))) {
|
||||
|
||||
}
|
||||
|
||||
void VendorExtensionService::start() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[VendorExtensionService] start()";
|
||||
});
|
||||
}
|
||||
|
||||
void VendorExtensionService::stop() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[VendorExtensionService] stop()";
|
||||
});
|
||||
}
|
||||
|
||||
void VendorExtensionService::pause() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[VendorExtensionService] pause()";
|
||||
});
|
||||
}
|
||||
|
||||
void VendorExtensionService::resume() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[VendorExtensionService] resume()";
|
||||
});
|
||||
}
|
||||
|
||||
void VendorExtensionService::fillFeatures(
|
||||
aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) {
|
||||
OPENAUTO_LOG(info) << "[VendorExtensionService] fillFeatures()";
|
||||
|
||||
auto *service = response.add_channels();
|
||||
service->set_id(static_cast<uint32_t>(channel_->getId()));
|
||||
|
||||
auto *vendorExtension = service->mutable_vendor_extension_service();
|
||||
}
|
||||
|
||||
void VendorExtensionService::onChannelError(const aasdk::error::Error &e) {
|
||||
OPENAUTO_LOG(error) << "[VendorExtensionService] onChannelError(): " << e.what();
|
||||
}
|
||||
|
||||
void VendorExtensionService::onChannelOpenRequest(
|
||||
const aap_protobuf::service::control::message::ChannelOpenRequest &request) {
|
||||
OPENAUTO_LOG(info) << "[VendorExtensionService] onChannelOpenRequest()";
|
||||
OPENAUTO_LOG(info) << "[VendorExtensionService] Channel Id: " << request.service_id() << ", Priority: "
|
||||
<< request.priority();
|
||||
|
||||
aap_protobuf::service::control::message::ChannelOpenResponse response;
|
||||
const aap_protobuf::shared::MessageStatus status = aap_protobuf::shared::MessageStatus::STATUS_SUCCESS;
|
||||
response.set_status(status);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&VendorExtensionService::onChannelError, this->shared_from_this(),
|
||||
std::placeholders::_1));
|
||||
channel_->sendChannelOpenResponse(response, std::move(promise));
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,214 +0,0 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <f1x/openauto/Common/Log.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/VideoService.hpp>
|
||||
#include <fstream>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace service
|
||||
{
|
||||
|
||||
VideoService::VideoService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IVideoOutput::Pointer videoOutput)
|
||||
: strand_(ioService)
|
||||
, channel_(std::make_shared<aasdk::channel::av::VideoServiceChannel>(strand_, std::move(messenger)))
|
||||
, videoOutput_(std::move(videoOutput))
|
||||
, session_(-1)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void VideoService::start()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[VideoService] start.";
|
||||
channel_->receive(this->shared_from_this());
|
||||
});
|
||||
}
|
||||
|
||||
void VideoService::stop()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[VideoService] stop.";
|
||||
videoOutput_->stop();
|
||||
});
|
||||
}
|
||||
|
||||
void VideoService::pause()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[VideoService] pause.";
|
||||
});
|
||||
}
|
||||
|
||||
void VideoService::resume()
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[VideoService] resume.";
|
||||
});
|
||||
}
|
||||
|
||||
void VideoService::onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[VideoService] open request, priority: " << request.priority();
|
||||
const aasdk::proto::enums::Status::Enum status = videoOutput_->open() ? aasdk::proto::enums::Status::OK : aasdk::proto::enums::Status::FAIL;
|
||||
OPENAUTO_LOG(info) << "[VideoService] open status: " << status;
|
||||
|
||||
aasdk::proto::messages::ChannelOpenResponse response;
|
||||
response.set_status(status);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&VideoService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
channel_->sendChannelOpenResponse(response, std::move(promise));
|
||||
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void VideoService::onAVChannelSetupRequest(const aasdk::proto::messages::AVChannelSetupRequest& request)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[VideoService] setup request, config index: " << request.config_index();
|
||||
const aasdk::proto::enums::AVChannelSetupStatus::Enum status = videoOutput_->init() ? aasdk::proto::enums::AVChannelSetupStatus::OK : aasdk::proto::enums::AVChannelSetupStatus::FAIL;
|
||||
OPENAUTO_LOG(info) << "[VideoService] setup status: " << status;
|
||||
|
||||
aasdk::proto::messages::AVChannelSetupResponse response;
|
||||
response.set_media_status(status);
|
||||
response.set_max_unacked(1);
|
||||
response.add_configs(0);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then(std::bind(&VideoService::sendVideoFocusIndication, this->shared_from_this()),
|
||||
std::bind(&VideoService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
channel_->sendAVChannelSetupResponse(response, std::move(promise));
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void VideoService::onAVChannelStartIndication(const aasdk::proto::messages::AVChannelStartIndication& indication)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[VideoService] start indication, session: " << indication.session();
|
||||
session_ = indication.session();
|
||||
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void VideoService::onAVChannelStopIndication(const aasdk::proto::messages::AVChannelStopIndication& indication)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[VideoService] stop indication, session: " << session_;
|
||||
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void VideoService::onAVMediaWithTimestampIndication(aasdk::messenger::Timestamp::ValueType timestamp, const aasdk::common::DataConstBuffer& buffer)
|
||||
{
|
||||
videoOutput_->write(timestamp, buffer);
|
||||
|
||||
aasdk::proto::messages::AVMediaAckIndication indication;
|
||||
indication.set_session(session_);
|
||||
indication.set_value(1);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&VideoService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
channel_->sendAVMediaAckIndication(indication, std::move(promise));
|
||||
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void VideoService::onAVMediaIndication(const aasdk::common::DataConstBuffer& buffer)
|
||||
{
|
||||
videoOutput_->write(0, buffer);
|
||||
|
||||
aasdk::proto::messages::AVMediaAckIndication indication;
|
||||
indication.set_session(session_);
|
||||
indication.set_value(1);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&VideoService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
channel_->sendAVMediaAckIndication(indication, std::move(promise));
|
||||
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void VideoService::onChannelError(const aasdk::error::Error& e)
|
||||
{
|
||||
OPENAUTO_LOG(error) << "[VideoService] channel error: " << e.what();
|
||||
}
|
||||
|
||||
void VideoService::fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[VideoService] fill features.";
|
||||
|
||||
auto* channelDescriptor = response.add_channels();
|
||||
channelDescriptor->set_channel_id(static_cast<uint32_t>(channel_->getId()));
|
||||
|
||||
auto* videoChannel = channelDescriptor->mutable_av_channel();
|
||||
videoChannel->set_stream_type(aasdk::proto::enums::AVStreamType::VIDEO);
|
||||
videoChannel->set_available_while_in_call(true);
|
||||
|
||||
auto* videoConfig1 = videoChannel->add_video_configs();
|
||||
videoConfig1->set_video_resolution(videoOutput_->getVideoResolution());
|
||||
videoConfig1->set_video_fps(videoOutput_->getVideoFPS());
|
||||
|
||||
const auto& videoMargins = videoOutput_->getVideoMargins();
|
||||
videoConfig1->set_margin_height(videoMargins.height());
|
||||
videoConfig1->set_margin_width(videoMargins.width());
|
||||
videoConfig1->set_dpi(videoOutput_->getScreenDPI());
|
||||
}
|
||||
|
||||
void VideoService::onVideoFocusRequest(const aasdk::proto::messages::VideoFocusRequest& request)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[VideoService] video focus request, display index: " << request.disp_index()
|
||||
<< ", focus mode: " << request.focus_mode()
|
||||
<< ", focus reason: " << request.focus_reason();
|
||||
|
||||
// stop video service on go back to openauto
|
||||
if (request.focus_mode() == 2) {
|
||||
OPENAUTO_LOG(info) << "[VideoService] Back to CSNG...";
|
||||
try {
|
||||
if (!std::ifstream("/tmp/entityexit")) {
|
||||
std::ofstream("/tmp/entityexit");
|
||||
}
|
||||
} catch (...) {
|
||||
OPENAUTO_LOG(error) << "[VideoService] Error in creating entityexit";
|
||||
}
|
||||
}
|
||||
|
||||
this->sendVideoFocusIndication();
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void VideoService::sendVideoFocusIndication()
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[VideoService] video focus indication.";
|
||||
|
||||
aasdk::proto::messages::VideoFocusIndication videoFocusIndication;
|
||||
videoFocusIndication.set_focus_mode(aasdk::proto::enums::VideoFocusMode::FOCUSED);
|
||||
videoFocusIndication.set_unrequested(false);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&VideoService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
channel_->sendVideoFocusIndication(videoFocusIndication, std::move(promise));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
122
src/autoapp/Service/WifiProjection/WifiProjectionService.cpp
Normal file
122
src/autoapp/Service/WifiProjection/WifiProjectionService.cpp
Normal file
@ -0,0 +1,122 @@
|
||||
/*
|
||||
* This file is part of openauto project.
|
||||
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||
*
|
||||
* openauto is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* openauto is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <f1x/openauto/Common/Log.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/WifiProjection/WifiProjectionService.hpp>
|
||||
#include <fstream>
|
||||
#include <QString>
|
||||
#include <QNetworkInterface>
|
||||
|
||||
|
||||
namespace f1x::openauto::autoapp::service::wifiprojection {
|
||||
WifiProjectionService::WifiProjectionService(boost::asio::io_service &ioService,
|
||||
aasdk::messenger::IMessenger::Pointer messenger,
|
||||
configuration::IConfiguration::Pointer configuration)
|
||||
: configuration_(std::move(configuration)),
|
||||
strand_(ioService),
|
||||
timer_(ioService),
|
||||
channel_(
|
||||
std::make_shared<aasdk::channel::wifiprojection::WifiProjectionService>(strand_, std::move(messenger))) {
|
||||
|
||||
}
|
||||
|
||||
void WifiProjectionService::start() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[WifiProjectionService] start()";
|
||||
});
|
||||
}
|
||||
|
||||
void WifiProjectionService::stop() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[WifiProjectionService] stop()";
|
||||
});
|
||||
}
|
||||
|
||||
void WifiProjectionService::pause() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[WifiProjectionService] pause()";
|
||||
});
|
||||
}
|
||||
|
||||
void WifiProjectionService::resume() {
|
||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[WifiProjectionService] resume()";
|
||||
});
|
||||
}
|
||||
|
||||
void WifiProjectionService::fillFeatures(
|
||||
aap_protobuf::service::control::message::ServiceDiscoveryResponse &response) {
|
||||
OPENAUTO_LOG(info) << "[WifiProjectionService] fillFeatures()";
|
||||
|
||||
auto *service = response.add_channels();
|
||||
service->set_id(static_cast<uint32_t>(channel_->getId()));
|
||||
|
||||
auto *wifiChannel = service->mutable_wifi_projection_service();
|
||||
wifiChannel->set_car_wifi_bssid(QNetworkInterface::interfaceFromName("wlan0").hardwareAddress().toStdString());
|
||||
}
|
||||
|
||||
void WifiProjectionService::onWifiCredentialsRequest(
|
||||
const aap_protobuf::service::wifiprojection::message::WifiCredentialsRequest &request) {
|
||||
|
||||
OPENAUTO_LOG(info) << "[WifiProjectionService] onWifiCredentialsRequest()";
|
||||
|
||||
aap_protobuf::service::wifiprojection::message::WifiCredentialsResponse response;
|
||||
|
||||
response.set_access_point_type(aap_protobuf::service::wifiprojection::message::AccessPointType::STATIC);
|
||||
response.set_car_wifi_ssid(configuration_->getParamFromFile("/etc/hostapd/hostapd.conf","ssid").toStdString());
|
||||
response.set_car_wifi_password(configuration_->getParamFromFile("/etc/hostapd/hostapd.conf","wpa_passphrase").toStdString());
|
||||
|
||||
// Might need to set WPA2_ENTERPRISE
|
||||
response.set_car_wifi_security_mode(
|
||||
aap_protobuf::service::wifiprojection::message::WifiSecurityMode::WPA2_PERSONAL);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&WifiProjectionService::onChannelError, this->shared_from_this(),
|
||||
std::placeholders::_1));
|
||||
channel_->sendWifiCredentialsResponse(response, std::move(promise));
|
||||
channel_->receive(this->shared_from_this());
|
||||
|
||||
}
|
||||
|
||||
void WifiProjectionService::onChannelOpenRequest(
|
||||
const aap_protobuf::service::control::message::ChannelOpenRequest &request) {
|
||||
OPENAUTO_LOG(info) << "[WifiProjectionService] onChannelOpenRequest()";
|
||||
OPENAUTO_LOG(debug) << "[WifiProjectionService] Channel Id: " << request.service_id() << ", Priority: "
|
||||
<< request.priority();
|
||||
|
||||
aap_protobuf::service::control::message::ChannelOpenResponse response;
|
||||
const aap_protobuf::shared::MessageStatus status = aap_protobuf::shared::MessageStatus::STATUS_SUCCESS;
|
||||
response.set_status(status);
|
||||
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([]() {}, std::bind(&WifiProjectionService::onChannelError, this->shared_from_this(),
|
||||
std::placeholders::_1));
|
||||
channel_->sendChannelOpenResponse(response, std::move(promise));
|
||||
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void WifiProjectionService::onChannelError(const aasdk::error::Error &e) {
|
||||
OPENAUTO_LOG(error) << "[WifiProjectionService] onChannelError(): " << e.what();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user