All modifications for AAP 1.6
This commit is contained in:
parent
0f317bdc3f
commit
5a2a305c04
156
CMakeLists.txt
156
CMakeLists.txt
@ -1,98 +1,119 @@
|
|||||||
cmake_minimum_required(VERSION 3.5.1)
|
cmake_minimum_required(VERSION 3.5.1)
|
||||||
|
|
||||||
project(openauto CXX)
|
project(openauto CXX)
|
||||||
|
|
||||||
set(CMAKE_AUTOMOC ON)
|
set(CMAKE_AUTOMOC ON)
|
||||||
set(CMAKE_AUTOUIC ON)
|
set(CMAKE_AUTOUIC ON)
|
||||||
set(CMAKE_AUTORCC ON)
|
set(CMAKE_AUTORCC ON)
|
||||||
set(base_directory ${CMAKE_CURRENT_SOURCE_DIR})
|
|
||||||
set(resources_directory ${base_directory}/assets)
|
|
||||||
set(sources_directory ${base_directory}/src)
|
|
||||||
set(include_directory ${base_directory}/include)
|
|
||||||
|
|
||||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${base_directory}/lib)
|
# Set Compile Versions
|
||||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${base_directory}/lib)
|
set(OPENAUTO_BUILD_DATE 20241028) # Binary Release Build Date
|
||||||
|
set(OPENAUTO_BUILD_RELEASE 1) # Binary Release Build Number (increment if released on same day)
|
||||||
|
set(OPENAUTO_BUILD_INCREMENTAL 1) # Binary Build Version - Increment for Each Build
|
||||||
|
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${base_directory}/bin)
|
# Configure CMAKE
|
||||||
set(EXECUTABLE_OUTPUT_PATH ${base_directory}/bin)
|
SET(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
set(Boost_USE_STATIC_LIBS OFF)
|
|
||||||
set(Boost_USE_MULTITHREADED ON)
|
|
||||||
set(Boost_USE_STATIC_RUNTIME OFF)
|
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake_modules/")
|
|
||||||
SET(CMAKE_CXX_STANDARD 14)
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_INIT} -Wall -pedantic -fPIC")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_INIT} -Wall -pedantic -fPIC")
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "-g -O3")
|
set(CMAKE_CXX_FLAGS_RELEASE "-g -O3")
|
||||||
|
|
||||||
|
# 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)
|
add_definitions(-DBOOST_ALL_DYN_LINK)
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
# Building on a Mac requires Abseil
|
||||||
|
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") # macOS
|
||||||
|
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)
|
||||||
|
include(FindProtobuf)
|
||||||
|
else ()
|
||||||
|
find_package(Protobuf REQUIRED)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
find_package(aap_protobuf REQUIRED)
|
||||||
|
find_package(aasdk REQUIRED)
|
||||||
find_package(Boost REQUIRED COMPONENTS system log OPTIONAL_COMPONENTS unit_test_framework)
|
find_package(Boost REQUIRED COMPONENTS system log OPTIONAL_COMPONENTS unit_test_framework)
|
||||||
find_package(libusb-1.0 REQUIRED)
|
find_package(libusb-1.0 REQUIRED)
|
||||||
find_package(Qt5 COMPONENTS Multimedia MultimediaWidgets Bluetooth Network)
|
find_package(Qt5 COMPONENTS Multimedia MultimediaWidgets Bluetooth Network)
|
||||||
find_package(Protobuf REQUIRED)
|
|
||||||
find_package(OpenSSL REQUIRED)
|
find_package(OpenSSL REQUIRED)
|
||||||
find_package(rtaudio REQUIRED)
|
find_package(rtaudio REQUIRED)
|
||||||
find_package(taglib REQUIRED)
|
find_package(taglib REQUIRED)
|
||||||
find_package(blkid REQUIRED)
|
find_package(blkid REQUIRED)
|
||||||
find_package(gps 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}
|
include_directories(${CMAKE_CURRENT_BINARY_DIR}
|
||||||
${Qt5Multimedia_INCLUDE_DIRS}
|
${Qt5Multimedia_INCLUDE_DIRS}
|
||||||
${Qt5MultimediaWidgets_INCLUDE_DIRS}
|
${Qt5MultimediaWidgets_INCLUDE_DIRS}
|
||||||
${Qt5Widgets_INCLUDE_DIRS}
|
${Qt5Widgets_INCLUDE_DIRS}
|
||||||
${Qt5Bluetooth_INCLUDE_DIRS}
|
${Qt5Bluetooth_INCLUDE_DIRS}
|
||||||
${Qt5Network_INCLUDE_DIRS}
|
${Qt5Network_INCLUDE_DIRS}
|
||||||
${Boost_INCLUDE_DIRS}
|
${Boost_INCLUDE_DIRS}
|
||||||
${PROTOBUF_INCLUDE_DIR}
|
${PROTOBUF_INCLUDE_DIR}
|
||||||
${OPENSSL_INCLUDE_DIR}
|
${AAP_PROTOBUF_INCLUDE_DIR}
|
||||||
${RTAUDIO_INCLUDE_DIRS}
|
${OPENSSL_INCLUDE_DIR}
|
||||||
${TAGLIB_INCLUDE_DIRS}
|
${RTAUDIO_INCLUDE_DIRS}
|
||||||
${BLKID_INCLUDE_DIRS}
|
${TAGLIB_INCLUDE_DIRS}
|
||||||
${AASDK_PROTO_INCLUDE_DIRS}
|
${BLKID_INCLUDE_DIRS}
|
||||||
${AASDK_INCLUDE_DIRS}
|
${BCM_HOST_INCLUDE_DIRS}
|
||||||
${BCM_HOST_INCLUDE_DIRS}
|
${ILCLIENT_INCLUDE_DIRS}
|
||||||
${ILCLIENT_INCLUDE_DIRS}
|
${include_directory})
|
||||||
${include_directory})
|
|
||||||
|
|
||||||
link_directories(${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
|
link_directories(${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
|
||||||
|
|
||||||
set(common_include_directory ${include_directory}/f1x/openauto/Common)
|
set(common_include_directory ${include_directory}/f1x/openauto/Common)
|
||||||
|
|
||||||
set(autoapp_sources_directory ${sources_directory}/autoapp)
|
set(autoapp_sources_directory ${sources_directory}/autoapp)
|
||||||
set(autoapp_include_directory ${include_directory}/f1x/openauto/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 ${common_include_directory}/*.hpp ${resources_directory}/*.qrc)
|
||||||
|
|
||||||
add_executable(autoapp ${autoapp_source_files})
|
add_executable(autoapp ${autoapp_source_files})
|
||||||
|
|
||||||
target_link_libraries(autoapp libusb
|
target_link_libraries(autoapp libusb
|
||||||
${Boost_LIBRARIES}
|
aap_protobuf
|
||||||
${Qt5Multimedia_LIBRARIES}
|
aasdk
|
||||||
${Qt5MultimediaWidgets_LIBRARIES}
|
${Boost_LIBRARIES}
|
||||||
${Qt5Bluetooth_LIBRARIES}
|
${Qt5Multimedia_LIBRARIES}
|
||||||
${Qt5Network_LIBRARIES}
|
${Qt5MultimediaWidgets_LIBRARIES}
|
||||||
${PROTOBUF_LIBRARIES}
|
${Qt5Bluetooth_LIBRARIES}
|
||||||
${BCM_HOST_LIBRARIES}
|
${Qt5Network_LIBRARIES}
|
||||||
${ILCLIENT_LIBRARIES}
|
${PROTOBUF_LIBRARIES}
|
||||||
${WINSOCK2_LIBRARIES}
|
${BCM_HOST_LIBRARIES}
|
||||||
${RTAUDIO_LIBRARIES}
|
${ILCLIENT_LIBRARIES}
|
||||||
${TAGLIB_LIBRARIES}
|
${WINSOCK2_LIBRARIES}
|
||||||
${BLKID_LIBRARIES}
|
${RTAUDIO_LIBRARIES}
|
||||||
${GPS_LIBRARIES}
|
${TAGLIB_LIBRARIES}
|
||||||
${AASDK_PROTO_LIBRARIES}
|
${BLKID_LIBRARIES}
|
||||||
${AASDK_LIBRARIES})
|
${GPS_LIBRARIES})
|
||||||
|
|
||||||
set(btservice_sources_directory ${sources_directory}/btservice)
|
set(btservice_sources_directory ${sources_directory}/btservice)
|
||||||
set(btservice_include_directory ${include_directory}/f1x/openauto/btservice)
|
set(btservice_include_directory ${include_directory}/f1x/openauto/btservice)
|
||||||
@ -100,10 +121,11 @@ file(GLOB_RECURSE btservice_source_files ${btservice_sources_directory}/*.cpp ${
|
|||||||
|
|
||||||
add_executable(btservice ${btservice_source_files})
|
add_executable(btservice ${btservice_source_files})
|
||||||
|
|
||||||
target_link_libraries(btservice
|
target_link_libraries(
|
||||||
${Boost_LIBRARIES}
|
btservice
|
||||||
${Qt5Bluetooth_LIBRARIES}
|
aap_protobuf
|
||||||
${Qt5Network_LIBRARIES}
|
${Boost_LIBRARIES}
|
||||||
${Qt5MultimediaWidgets_LIBRARIES}
|
${Qt5Bluetooth_LIBRARIES}
|
||||||
${PROTOBUF_LIBRARIES}
|
${Qt5Network_LIBRARIES}
|
||||||
${AASDK_PROTO_LIBRARIES})
|
${Qt5MultimediaWidgets_LIBRARIES}
|
||||||
|
${PROTOBUF_LIBRARIES})
|
||||||
|
3
Dockerfile
Normal file
3
Dockerfile
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
FROM scratch
|
||||||
|
ADD rootfs.tar.xz /
|
||||||
|
CMD ["bash"]
|
@ -18,11 +18,11 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <f1x/aasdk/USB/IUSBHub.hpp>
|
#include <aasdk/USB/IUSBHub.hpp>
|
||||||
#include <f1x/aasdk/USB/IConnectedAccessoriesEnumerator.hpp>
|
#include <aasdk/USB/IConnectedAccessoriesEnumerator.hpp>
|
||||||
#include <f1x/aasdk/USB/USBWrapper.hpp>
|
#include <aasdk/USB/USBWrapper.hpp>
|
||||||
#include <f1x/aasdk/TCP/ITCPWrapper.hpp>
|
#include <aasdk/TCP/ITCPWrapper.hpp>
|
||||||
#include <f1x/aasdk/TCP/ITCPEndpoint.hpp>
|
#include <aasdk/TCP/ITCPEndpoint.hpp>
|
||||||
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntityEventHandler.hpp>
|
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntityEventHandler.hpp>
|
||||||
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntityFactory.hpp>
|
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntityFactory.hpp>
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
@ -88,10 +89,10 @@ public:
|
|||||||
QString readFileContent(QString fileName) const override;
|
QString readFileContent(QString fileName) const override;
|
||||||
QString getParamFromFile(QString fileName, QString searchString) const override;
|
QString getParamFromFile(QString fileName, QString searchString) const override;
|
||||||
|
|
||||||
aasdk::proto::enums::VideoFPS::Enum getVideoFPS() const override;
|
aap_protobuf::service::media::shared::message::VideoFrameRateType getVideoFPS() const override;
|
||||||
void setVideoFPS(aasdk::proto::enums::VideoFPS::Enum value) override;
|
void setVideoFPS(aap_protobuf::service::media::shared::message::VideoFrameRateType value) override;
|
||||||
aasdk::proto::enums::VideoResolution::Enum getVideoResolution() const override;
|
aap_protobuf::service::media::shared::message::VideoCodecResolutionType getVideoResolution() const override;
|
||||||
void setVideoResolution(aasdk::proto::enums::VideoResolution::Enum value) override;
|
void setVideoResolution(aap_protobuf::service::media::shared::message::VideoCodecResolutionType value) override;
|
||||||
size_t getScreenDPI() const override;
|
size_t getScreenDPI() const override;
|
||||||
void setScreenDPI(size_t value) override;
|
void setScreenDPI(size_t value) override;
|
||||||
void setOMXLayerIndex(int32_t value) override;
|
void setOMXLayerIndex(int32_t value) override;
|
||||||
@ -113,14 +114,18 @@ public:
|
|||||||
|
|
||||||
bool musicAudioChannelEnabled() const override;
|
bool musicAudioChannelEnabled() const override;
|
||||||
void setMusicAudioChannelEnabled(bool value) override;
|
void setMusicAudioChannelEnabled(bool value) override;
|
||||||
bool speechAudioChannelEnabled() const override;
|
bool guidanceAudioChannelEnabled() const override;
|
||||||
void setSpeechAudioChannelEnabled(bool value) 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;
|
AudioOutputBackendType getAudioOutputBackendType() const override;
|
||||||
void setAudioOutputBackendType(AudioOutputBackendType value) override;
|
void setAudioOutputBackendType(AudioOutputBackendType value) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void readButtonCodes(boost::property_tree::ptree& iniConfig);
|
void readButtonCodes(boost::property_tree::ptree& iniConfig);
|
||||||
void insertButtonCode(boost::property_tree::ptree& iniConfig, const std::string& buttonCodeKey, aasdk::proto::enums::ButtonCode::Enum buttonCode);
|
void insertButtonCode(boost::property_tree::ptree& iniConfig, const std::string& buttonCodeKey, aap_protobuf::service::media::sink::KeyCode buttonCode);
|
||||||
void writeButtonCodes(boost::property_tree::ptree& iniConfig);
|
void writeButtonCodes(boost::property_tree::ptree& iniConfig);
|
||||||
|
|
||||||
HandednessOfTrafficType handednessOfTrafficType_;
|
HandednessOfTrafficType handednessOfTrafficType_;
|
||||||
@ -143,8 +148,8 @@ private:
|
|||||||
bool showAutoPlay_;
|
bool showAutoPlay_;
|
||||||
bool instantPlay_;
|
bool instantPlay_;
|
||||||
|
|
||||||
aasdk::proto::enums::VideoFPS::Enum videoFPS_;
|
aap_protobuf::service::media::shared::message::VideoFrameRateType videoFPS_;
|
||||||
aasdk::proto::enums::VideoResolution::Enum videoResolution_;
|
aap_protobuf::service::media::shared::message::VideoCodecResolutionType videoResolution_;
|
||||||
size_t screenDPI_;
|
size_t screenDPI_;
|
||||||
int32_t omxLayerIndex_;
|
int32_t omxLayerIndex_;
|
||||||
QRect videoMargins_;
|
QRect videoMargins_;
|
||||||
@ -153,8 +158,11 @@ private:
|
|||||||
ButtonCodes buttonCodes_;
|
ButtonCodes buttonCodes_;
|
||||||
BluetoothAdapterType bluetoothAdapterType_;
|
BluetoothAdapterType bluetoothAdapterType_;
|
||||||
std::string bluetoothRemoteAdapterAddress_;
|
std::string bluetoothRemoteAdapterAddress_;
|
||||||
bool musicAudioChannelEnabled_;
|
bool _audioChannelEnabledMedia;
|
||||||
bool speechAudiochannelEnabled_;
|
bool _audioChannelEnabledGuidance;
|
||||||
|
bool _audioChannelEnabledSystem;
|
||||||
|
bool _audioChannelEnabledTelephony;
|
||||||
|
|
||||||
AudioOutputBackendType audioOutputBackendType_;
|
AudioOutputBackendType audioOutputBackendType_;
|
||||||
|
|
||||||
static const std::string cConfigFileName;
|
static const std::string cConfigFileName;
|
||||||
@ -188,8 +196,15 @@ private:
|
|||||||
static const std::string cVideoMarginWidth;
|
static const std::string cVideoMarginWidth;
|
||||||
static const std::string cVideoMarginHeight;
|
static const std::string cVideoMarginHeight;
|
||||||
|
|
||||||
static const std::string cAudioMusicAudioChannelEnabled;
|
struct Audio {
|
||||||
static const std::string cAudioSpeechAudioChannelEnabled;
|
struct Channel {
|
||||||
|
static const std::string cMediaEnabled;
|
||||||
|
static const std::string cGuidanceEnabled;
|
||||||
|
static const std::string cSystemEnabled;
|
||||||
|
static const std::string cTelephonyEnabled;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
static const std::string cAudioOutputBackendType;
|
static const std::string cAudioOutputBackendType;
|
||||||
|
|
||||||
static const std::string cBluetoothAdapterTypeKey;
|
static const std::string cBluetoothAdapterTypeKey;
|
||||||
|
@ -20,9 +20,9 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <QRect>
|
#include <QRect>
|
||||||
#include <aasdk_proto/VideoFPSEnum.pb.h>
|
#include <aap_protobuf/service/media/shared/message/VideoFrameRateType.pb.h>
|
||||||
#include <aasdk_proto/VideoResolutionEnum.pb.h>
|
#include <aap_protobuf/service/media/shared/message/VideoCodecResolutionType.pb.h>
|
||||||
#include <aasdk_proto/ButtonCodeEnum.pb.h>
|
#include <aap_protobuf/service/media/sink/KeyCode.pb.h>
|
||||||
#include <f1x/openauto/autoapp/Configuration/BluetootAdapterType.hpp>
|
#include <f1x/openauto/autoapp/Configuration/BluetootAdapterType.hpp>
|
||||||
#include <f1x/openauto/autoapp/Configuration/HandednessOfTrafficType.hpp>
|
#include <f1x/openauto/autoapp/Configuration/HandednessOfTrafficType.hpp>
|
||||||
#include <f1x/openauto/autoapp/Configuration/AudioOutputBackendType.hpp>
|
#include <f1x/openauto/autoapp/Configuration/AudioOutputBackendType.hpp>
|
||||||
@ -40,7 +40,7 @@ class IConfiguration
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::shared_ptr<IConfiguration> Pointer;
|
typedef std::shared_ptr<IConfiguration> Pointer;
|
||||||
typedef std::vector<aasdk::proto::enums::ButtonCode::Enum> ButtonCodes;
|
typedef std::vector<aap_protobuf::service::media::sink::KeyCode> ButtonCodes;
|
||||||
|
|
||||||
virtual ~IConfiguration() = default;
|
virtual ~IConfiguration() = default;
|
||||||
|
|
||||||
@ -92,10 +92,10 @@ public:
|
|||||||
virtual QString readFileContent(QString fileName) const = 0;
|
virtual QString readFileContent(QString fileName) const = 0;
|
||||||
virtual QString getParamFromFile(QString fileName, QString searchString) const = 0;
|
virtual QString getParamFromFile(QString fileName, QString searchString) const = 0;
|
||||||
|
|
||||||
virtual aasdk::proto::enums::VideoFPS::Enum getVideoFPS() const = 0;
|
virtual aap_protobuf::service::media::shared::message::VideoFrameRateType getVideoFPS() const = 0;
|
||||||
virtual void setVideoFPS(aasdk::proto::enums::VideoFPS::Enum value) = 0;
|
virtual void setVideoFPS(aap_protobuf::service::media::shared::message::VideoFrameRateType value) = 0;
|
||||||
virtual aasdk::proto::enums::VideoResolution::Enum getVideoResolution() const = 0;
|
virtual aap_protobuf::service::media::shared::message::VideoCodecResolutionType getVideoResolution() const = 0;
|
||||||
virtual void setVideoResolution(aasdk::proto::enums::VideoResolution::Enum value) = 0;
|
virtual void setVideoResolution(aap_protobuf::service::media::shared::message::VideoCodecResolutionType value) = 0;
|
||||||
virtual size_t getScreenDPI() const = 0;
|
virtual size_t getScreenDPI() const = 0;
|
||||||
virtual void setScreenDPI(size_t value) = 0;
|
virtual void setScreenDPI(size_t value) = 0;
|
||||||
virtual void setOMXLayerIndex(int32_t value) = 0;
|
virtual void setOMXLayerIndex(int32_t value) = 0;
|
||||||
@ -117,8 +117,12 @@ public:
|
|||||||
|
|
||||||
virtual bool musicAudioChannelEnabled() const = 0;
|
virtual bool musicAudioChannelEnabled() const = 0;
|
||||||
virtual void setMusicAudioChannelEnabled(bool value) = 0;
|
virtual void setMusicAudioChannelEnabled(bool value) = 0;
|
||||||
virtual bool speechAudioChannelEnabled() const = 0;
|
virtual bool guidanceAudioChannelEnabled() const = 0;
|
||||||
virtual void setSpeechAudioChannelEnabled(bool value) = 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 AudioOutputBackendType getAudioOutputBackendType() const = 0;
|
||||||
virtual void setAudioOutputBackendType(AudioOutputBackendType value) = 0;
|
virtual void setAudioOutputBackendType(AudioOutputBackendType value) = 0;
|
||||||
};
|
};
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <f1x/aasdk/IO/Promise.hpp>
|
#include <aasdk/IO/Promise.hpp>
|
||||||
#include <f1x/aasdk/Common/Data.hpp>
|
#include <aasdk/Common/Data.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
{
|
{
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <f1x/aasdk/Messenger/Timestamp.hpp>
|
#include <aasdk/Messenger/Timestamp.hpp>
|
||||||
#include <f1x/aasdk/Common/Data.hpp>
|
#include <aasdk/Common/Data.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
{
|
{
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <f1x/aasdk/IO/Promise.hpp>
|
#include <aasdk/IO/Promise.hpp>
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QRect>
|
#include <QRect>
|
||||||
#include <f1x/aasdk/IO/Promise.hpp>
|
#include <aasdk/IO/Promise.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/InputEvent.hpp>
|
#include <f1x/openauto/autoapp/Projection/InputEvent.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
@ -37,7 +37,7 @@ class IInputDevice
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::shared_ptr<IInputDevice> Pointer;
|
typedef std::shared_ptr<IInputDevice> Pointer;
|
||||||
typedef std::vector<aasdk::proto::enums::ButtonCode::Enum> ButtonCodes;
|
typedef std::vector<aap_protobuf::service::media::sink::KeyCode> ButtonCodes;
|
||||||
|
|
||||||
virtual ~IInputDevice() = default;
|
virtual ~IInputDevice() = default;
|
||||||
virtual void start(IInputDeviceEventHandler& eventHandler) = 0;
|
virtual void start(IInputDeviceEventHandler& eventHandler) = 0;
|
||||||
|
@ -20,9 +20,10 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <QRect>
|
#include <QRect>
|
||||||
#include <aasdk_proto/VideoFPSEnum.pb.h>
|
#include <aasdk/Common/Data.hpp>
|
||||||
#include <aasdk_proto/VideoResolutionEnum.pb.h>
|
#include <aasdk/Messenger/Timestamp.hpp>
|
||||||
#include <f1x/aasdk/Common/Data.hpp>
|
#include <aap_protobuf/service/media/shared/message/VideoFrameRateType.pb.h>
|
||||||
|
#include <aap_protobuf/service/media/shared/message/VideoCodecResolutionType.pb.h>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
{
|
{
|
||||||
@ -43,13 +44,14 @@ public:
|
|||||||
|
|
||||||
virtual bool open() = 0;
|
virtual bool open() = 0;
|
||||||
virtual bool init() = 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 void stop() = 0;
|
||||||
|
|
||||||
virtual aasdk::proto::enums::VideoFPS::Enum getVideoFPS() const = 0;
|
virtual aap_protobuf::service::media::shared::message::VideoFrameRateType getVideoFPS() const = 0;
|
||||||
virtual aasdk::proto::enums::VideoResolution::Enum getVideoResolution() const = 0;
|
virtual aap_protobuf::service::media::shared::message::VideoCodecResolutionType getVideoResolution() const = 0;
|
||||||
virtual size_t getScreenDPI() const = 0;
|
virtual size_t getScreenDPI() const = 0;
|
||||||
virtual QRect getVideoMargins() const = 0;
|
virtual QRect getVideoMargins() const = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,9 +18,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <aasdk_proto/ButtonCodeEnum.pb.h>
|
#include <aap_protobuf/service/media/sink/KeyCode.pb.h>
|
||||||
#include <aasdk_proto/TouchActionEnum.pb.h>
|
#include <aap_protobuf/service/input/message/TouchAction.pb.h>
|
||||||
#include <f1x/aasdk/IO/Promise.hpp>
|
#include <aasdk/IO/Promise.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
{
|
{
|
||||||
@ -49,12 +49,12 @@ struct ButtonEvent
|
|||||||
{
|
{
|
||||||
ButtonEventType type;
|
ButtonEventType type;
|
||||||
WheelDirection wheelDirection;
|
WheelDirection wheelDirection;
|
||||||
aasdk::proto::enums::ButtonCode::Enum code;
|
aap_protobuf::service::media::sink::KeyCode code;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TouchEvent
|
struct TouchEvent
|
||||||
{
|
{
|
||||||
aasdk::proto::enums::TouchAction::Enum type;
|
aap_protobuf::service::input::message::TouchAction type;
|
||||||
uint32_t x;
|
uint32_t x;
|
||||||
uint32_t y;
|
uint32_t y;
|
||||||
uint32_t pointerId;
|
uint32_t pointerId;
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#include <QIODevice>
|
#include <QIODevice>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <boost/circular_buffer.hpp>
|
#include <boost/circular_buffer.hpp>
|
||||||
#include <f1x/aasdk/Common/Data.hpp>
|
#include <aasdk/Common/Data.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
{
|
{
|
||||||
|
@ -35,8 +35,8 @@ class VideoOutput: public IVideoOutput
|
|||||||
public:
|
public:
|
||||||
VideoOutput(configuration::IConfiguration::Pointer configuration);
|
VideoOutput(configuration::IConfiguration::Pointer configuration);
|
||||||
|
|
||||||
aasdk::proto::enums::VideoFPS::Enum getVideoFPS() const override;
|
aap_protobuf::service::media::shared::message::VideoFrameRateType getVideoFPS() const override;
|
||||||
aasdk::proto::enums::VideoResolution::Enum getVideoResolution() const override;
|
aap_protobuf::service::media::shared::message::VideoCodecResolutionType getVideoResolution() const override;
|
||||||
size_t getScreenDPI() const override;
|
size_t getScreenDPI() const override;
|
||||||
QRect getVideoMargins() const override;
|
QRect getVideoMargins() const override;
|
||||||
|
|
||||||
|
@ -19,10 +19,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#include <f1x/aasdk/Transport/ITransport.hpp>
|
#include <aasdk/Transport/ITransport.hpp>
|
||||||
#include <f1x/aasdk/Channel/Control/IControlServiceChannel.hpp>
|
#include <aasdk/Channel/Control/IControlServiceChannel.hpp>
|
||||||
#include <f1x/aasdk/Channel/Control/IControlServiceChannelEventHandler.hpp>
|
#include <aasdk/Channel/Control/IControlServiceChannelEventHandler.hpp>
|
||||||
#include <f1x/aasdk/Channel/AV/VideoServiceChannel.hpp>
|
#include <aasdk/Channel/MediaSink/Video/VideoChannel.hpp>
|
||||||
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
||||||
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntity.hpp>
|
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntity.hpp>
|
||||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
||||||
@ -53,14 +53,17 @@ public:
|
|||||||
void stop() override;
|
void stop() override;
|
||||||
void pause() override;
|
void pause() override;
|
||||||
void resume() 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 onHandshake(const aasdk::common::DataConstBuffer& payload) override;
|
||||||
void onServiceDiscoveryRequest(const aasdk::proto::messages::ServiceDiscoveryRequest& request) override;
|
void onServiceDiscoveryRequest(const aap_protobuf::channel::control::servicediscovery::event::ServiceDiscoveryRequest& request) override;
|
||||||
void onAudioFocusRequest(const aasdk::proto::messages::AudioFocusRequest& request) override;
|
void onAudioFocusRequest(const aap_protobuf::channel::control::focus::audio::event::AudioFocusRequest& request) override;
|
||||||
void onShutdownRequest(const aasdk::proto::messages::ShutdownRequest& request) override;
|
void onByeByeRequest(const aap_protobuf::channel::control::byebye::event::ByeByeRequest& request) override;
|
||||||
void onShutdownResponse(const aasdk::proto::messages::ShutdownResponse& response) override;
|
void onByeByeResponse(const aap_protobuf::channel::control::byebye::notification::ByeByeResponse& response) override;
|
||||||
void onNavigationFocusRequest(const aasdk::proto::messages::NavigationFocusRequest& request) override;
|
void onNavigationFocusRequest(const aap_protobuf::channel::control::focus::navigation::event::NavFocusRequestNotification& request) override;
|
||||||
void onPingResponse(const aasdk::proto::messages::PingResponse& response) override;
|
void onVoiceSessionRequest(const aap_protobuf::channel::control::voice::VoiceSessionNotification &request) override;
|
||||||
|
void onPingResponse(const aap_protobuf::channel::control::ping::PingResponse& response) override;
|
||||||
|
void onPingRequest(const aap_protobuf::channel::control::ping::PingRequest& request) override;
|
||||||
void onChannelError(const aasdk::error::Error& e) override;
|
void onChannelError(const aasdk::error::Error& e) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#include <f1x/aasdk/Transport/ITransport.hpp>
|
#include <aasdk/Transport/ITransport.hpp>
|
||||||
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
||||||
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntityFactory.hpp>
|
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntityFactory.hpp>
|
||||||
#include <f1x/openauto/autoapp/Service/IServiceFactory.hpp>
|
#include <f1x/openauto/autoapp/Service/IServiceFactory.hpp>
|
||||||
|
@ -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 <f1x/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 <f1x/aasdk/Channel/AV/IAudioServiceChannel.hpp>
|
|
||||||
#include <f1x/aasdk/Channel/AV/IAudioServiceChannelEventHandler.hpp>
|
|
||||||
#include <f1x/openauto/autoapp/Projection/IAudioOutput.hpp>
|
|
||||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
|
||||||
|
|
||||||
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,66 @@
|
|||||||
|
/*
|
||||||
|
* 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::channel::control::servicediscovery::notification::ServiceDiscoveryResponse &response) override;
|
||||||
|
|
||||||
|
void onChannelOpenRequest(const aap_protobuf::channel::ChannelOpenRequest &request) override;
|
||||||
|
|
||||||
|
void onBluetoothPairingRequest(
|
||||||
|
const aap_protobuf::channel::bluetooth::event::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::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 <f1x/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::channel::control::servicediscovery::notification::ServiceDiscoveryResponse &response) override;
|
||||||
|
|
||||||
|
void onChannelOpenRequest(const aap_protobuf::channel::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_;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <f1x/aasdk/Error/Error.hpp>
|
#include <aasdk/Error/Error.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
{
|
{
|
||||||
|
@ -18,8 +18,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <f1x/aasdk/TCP/ITCPEndpoint.hpp>
|
#include <aasdk/TCP/ITCPEndpoint.hpp>
|
||||||
#include <f1x/aasdk/USB/IAOAPDevice.hpp>
|
#include <aasdk/USB/IAOAPDevice.hpp>
|
||||||
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntity.hpp>
|
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntity.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <f1x/aasdk/IO/Promise.hpp>
|
#include <aasdk/IO/Promise.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
{
|
{
|
||||||
|
@ -20,7 +20,9 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <aasdk_proto/ServiceDiscoveryResponseMessage.pb.h>
|
#include <f1x/openauto/Common/Log.hpp>
|
||||||
|
#include <aap_protobuf/channel/control/servicediscovery/notification//ServiceDiscoveryResponse.pb.h>
|
||||||
|
#include <aap_protobuf/shared/MessageStatus.pb.h>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
{
|
{
|
||||||
@ -42,7 +44,7 @@ public:
|
|||||||
virtual void stop() = 0;
|
virtual void stop() = 0;
|
||||||
virtual void pause() = 0;
|
virtual void pause() = 0;
|
||||||
virtual void resume() = 0;
|
virtual void resume() = 0;
|
||||||
virtual void fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response) = 0;
|
virtual void fillFeatures(aap_protobuf::channel::control::servicediscovery::notification::ServiceDiscoveryResponse& response) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::vector<IService::Pointer> ServiceList;
|
typedef std::vector<IService::Pointer> ServiceList;
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <f1x/aasdk/Messenger/IMessenger.hpp>
|
#include <aasdk/Messenger/IMessenger.hpp>
|
||||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
|
@ -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 <f1x/aasdk/Channel/Input/InputServiceChannel.hpp>
|
|
||||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
|
||||||
#include <f1x/openauto/autoapp/Projection/IInputDevice.hpp>
|
|
||||||
#include <f1x/openauto/autoapp/Projection/IInputDeviceEventHandler.hpp>
|
|
||||||
|
|
||||||
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/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::channel::control::servicediscovery::notification::ServiceDiscoveryResponse &response) override;
|
||||||
|
|
||||||
|
|
||||||
|
void onChannelOpenRequest(const aap_protobuf::channel::ChannelOpenRequest &request) override;
|
||||||
|
|
||||||
|
void onBindingRequest(const aap_protobuf::channel::input::event::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<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::channel::control::servicediscovery::notification::ServiceDiscoveryResponse &response) override;
|
||||||
|
|
||||||
|
void onChannelOpenRequest(const aap_protobuf::channel::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::channel::control::servicediscovery::notification::ServiceDiscoveryResponse &response) override;
|
||||||
|
|
||||||
|
void onChannelOpenRequest(const aap_protobuf::channel::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::channel::control::servicediscovery::notification::ServiceDiscoveryResponse &response) override;
|
||||||
|
|
||||||
|
void onChannelOpenRequest(const aap_protobuf::channel::ChannelOpenRequest &request) override;
|
||||||
|
|
||||||
|
void onMediaChannelSetupRequest(
|
||||||
|
const aap_protobuf::channel::media::event::Setup &request) override;
|
||||||
|
|
||||||
|
void onMediaChannelStartIndication(
|
||||||
|
const aap_protobuf::channel::media::event::Start &indication) override;
|
||||||
|
|
||||||
|
void onMediaChannelStopIndication(
|
||||||
|
const aap_protobuf::channel::media::event::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
|
#pragma once
|
||||||
|
|
||||||
#include <f1x/aasdk/Messenger/IMessenger.hpp>
|
#include <f1x/openauto/autoapp/Service/MediaSink/AudioMediaSinkService.hpp>
|
||||||
#include <f1x/openauto/autoapp/Service/AudioService.hpp>
|
#include <aasdk/Channel/MediaSink/Audio/Channel/GuidanceAudioChannel.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x {
|
||||||
{
|
namespace openauto {
|
||||||
namespace openauto
|
namespace autoapp {
|
||||||
{
|
namespace service {
|
||||||
namespace autoapp
|
namespace mediasink {
|
||||||
{
|
class GuidanceAudioService : public AudioMediaSinkService {
|
||||||
namespace service
|
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
|
#pragma once
|
||||||
|
|
||||||
#include <f1x/aasdk/Messenger/IMessenger.hpp>
|
#include <f1x/openauto/autoapp/Service/MediaSink/AudioMediaSinkService.hpp>
|
||||||
#include <f1x/openauto/autoapp/Service/AudioService.hpp>
|
#include <aasdk/Channel/MediaSink/Audio/Channel/MediaAudioChannel.hpp>
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
|
||||||
{
|
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace service
|
|
||||||
{
|
|
||||||
|
|
||||||
class MediaAudioService: public AudioService
|
namespace f1x {
|
||||||
{
|
namespace openauto {
|
||||||
public:
|
namespace autoapp {
|
||||||
MediaAudioService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IAudioOutput::Pointer audioOutput);
|
namespace service {
|
||||||
};
|
namespace mediasink {
|
||||||
|
class MediaAudioService : public AudioMediaSinkService {
|
||||||
|
public:
|
||||||
|
MediaAudioService(boost::asio::io_service &ioService,
|
||||||
|
aasdk::messenger::IMessenger::Pointer messenger,
|
||||||
|
projection::IAudioOutput::Pointer audioOutput);
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
@ -16,25 +16,28 @@
|
|||||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <f1x/aasdk/Channel/AV/MediaAudioServiceChannel.hpp>
|
#pragma once
|
||||||
#include <f1x/openauto/autoapp/Service/MediaAudioService.hpp>
|
|
||||||
|
|
||||||
namespace f1x
|
#include <f1x/openauto/autoapp/Service/MediaSink/AudioMediaSinkService.hpp>
|
||||||
{
|
#include <aasdk/Channel/MediaSink/Audio/Channel/SystemAudioChannel.hpp>
|
||||||
namespace openauto
|
|
||||||
{
|
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace service
|
|
||||||
{
|
|
||||||
|
|
||||||
MediaAudioService::MediaAudioService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IAudioOutput::Pointer audioOutput)
|
namespace f1x {
|
||||||
: AudioService(ioService, std::make_shared<aasdk::channel::av::MediaAudioServiceChannel>(strand_, std::move(messenger)), std::move(audioOutput))
|
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::channel::control::servicediscovery::notification::ServiceDiscoveryResponse &response) override;
|
||||||
|
|
||||||
|
void onChannelOpenRequest(const aap_protobuf::channel::ChannelOpenRequest &request) override;
|
||||||
|
|
||||||
|
void onMediaChannelSetupRequest(
|
||||||
|
const aap_protobuf::channel::media::event::Setup &request) override;
|
||||||
|
|
||||||
|
void onMediaChannelStartIndication(
|
||||||
|
const aap_protobuf::channel::media::event::Start &indication) override;
|
||||||
|
|
||||||
|
void onMediaChannelStopIndication(
|
||||||
|
const aap_protobuf::channel::media::event::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::channel::control::focus::video::event::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
|
#pragma once
|
||||||
|
|
||||||
#include <f1x/aasdk/Messenger/IMessenger.hpp>
|
#include <f1x/openauto/autoapp/Service/MediaSink/VideoMediaSinkService.hpp>
|
||||||
#include <f1x/openauto/autoapp/Service/AudioService.hpp>
|
#include <aasdk/Channel/MediaSink/Video/Channel/VideoChannel.hpp>
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
|
||||||
{
|
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace service
|
|
||||||
{
|
|
||||||
|
|
||||||
class SpeechAudioService: public AudioService
|
namespace f1x {
|
||||||
{
|
namespace openauto {
|
||||||
public:
|
namespace autoapp {
|
||||||
SpeechAudioService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IAudioOutput::Pointer audioOutput);
|
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 audioOutput);
|
||||||
|
|
||||||
|
void start() override;
|
||||||
|
|
||||||
|
void stop() override;
|
||||||
|
|
||||||
|
void pause() override;
|
||||||
|
|
||||||
|
void resume() override;
|
||||||
|
|
||||||
|
void fillFeatures(
|
||||||
|
aap_protobuf::channel::control::servicediscovery::notification::ServiceDiscoveryResponse &response) override;
|
||||||
|
|
||||||
|
void onChannelOpenRequest(const aap_protobuf::channel::ChannelOpenRequest &request) override;
|
||||||
|
|
||||||
|
void onMediaChannelSetupRequest(
|
||||||
|
const aap_protobuf::channel::media::event::Setup &request) override;
|
||||||
|
|
||||||
|
void onMediaSourceOpenRequest(
|
||||||
|
const aap_protobuf::service::media::source::message::MicrophoneRequest &request) override;
|
||||||
|
|
||||||
|
void onMediaChannelAckIndication(
|
||||||
|
const aap_protobuf::service::media::source::message::MediaSourceMediaAckIndication &indication) override;
|
||||||
|
|
||||||
|
void onChannelError(const aasdk::error::Error &e) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
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,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/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::channel::control::servicediscovery::notification::ServiceDiscoveryResponse &response) override;
|
||||||
|
|
||||||
|
void onChannelOpenRequest(const aap_protobuf::channel::ChannelOpenRequest &request) override;
|
||||||
|
|
||||||
|
void onChannelError(const aasdk::error::Error &e) 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::channel::control::servicediscovery::notification::ServiceDiscoveryResponse &response) override;
|
||||||
|
|
||||||
|
void onChannelOpenRequest(const aap_protobuf::channel::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::channel::control::servicediscovery::notification::ServiceDiscoveryResponse &response) override;
|
||||||
|
|
||||||
|
void onChannelOpenRequest(const aap_protobuf::channel::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_;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
* 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 <gps.h>
|
||||||
|
#include <aasdk/Channel/Sensor/SensorService.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 sensor {
|
||||||
|
class SensorService :
|
||||||
|
public aasdk::channel::sensor::ISensorServiceEventHandler,
|
||||||
|
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(aap_protobuf::channel::control::servicediscovery::notification::ServiceDiscoveryResponse &response) override;
|
||||||
|
|
||||||
|
void onChannelOpenRequest(const aap_protobuf::channel::ChannelOpenRequest &request) override;
|
||||||
|
|
||||||
|
void onSensorStartRequest(
|
||||||
|
const aap_protobuf::channel::sensor::event::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::SensorService::Pointer channel_;
|
||||||
|
struct gps_data_t gpsData_;
|
||||||
|
bool gpsEnabled_ = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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 <gps.h>
|
|
||||||
#include <f1x/aasdk/Channel/Sensor/SensorServiceChannel.hpp>
|
|
||||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
|
||||||
{
|
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace service
|
|
||||||
{
|
|
||||||
|
|
||||||
class SensorService: public aasdk::channel::sensor::ISensorServiceChannelEventHandler, public IService, public std::enable_shared_from_this<SensorService>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SensorService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger);
|
|
||||||
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:
|
|
||||||
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_;
|
|
||||||
struct gps_data_t gpsData_;
|
|
||||||
bool gpsEnabled_ = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -18,39 +18,37 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
#include <aasdk/Channel/Bluetooth/BluetoothService.hpp>
|
||||||
|
#include <f1x/openauto/autoapp/Projection/IBluetoothDevice.hpp>
|
||||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
||||||
#include <boost/asio/io_service.hpp>
|
|
||||||
#include <f1x/aasdk/Messenger/IMessenger.hpp>
|
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x {
|
||||||
{
|
namespace openauto {
|
||||||
namespace openauto
|
namespace autoapp {
|
||||||
{
|
namespace service {
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace service
|
|
||||||
{
|
|
||||||
|
|
||||||
class WifiService: public IService, public std::enable_shared_from_this<WifiService>
|
class Service
|
||||||
{
|
: public IService {
|
||||||
public:
|
public:
|
||||||
typedef std::shared_ptr<WifiService> Pointer;
|
Service(boost::asio::io_service &ioService);
|
||||||
|
|
||||||
WifiService(configuration::IConfiguration::Pointer configuration);
|
void start() override;
|
||||||
|
|
||||||
void start() override;
|
void stop() override;
|
||||||
void stop() override;
|
|
||||||
void pause() override;
|
|
||||||
void resume() override;
|
|
||||||
void fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response) override;
|
|
||||||
|
|
||||||
private:
|
void pause() override;
|
||||||
using std::enable_shared_from_this<WifiService>::shared_from_this;
|
|
||||||
configuration::IConfiguration::Pointer configuration_;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
void resume() override;
|
||||||
}
|
|
||||||
}
|
void fillFeatures(aap_protobuf::channel::control::servicediscovery::notification::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/Service/IServiceFactory.hpp>
|
||||||
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x {
|
||||||
{
|
namespace openauto {
|
||||||
namespace openauto
|
namespace autoapp {
|
||||||
{
|
namespace service {
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace service
|
|
||||||
{
|
|
||||||
|
|
||||||
class ServiceFactory: public IServiceFactory
|
class ServiceFactory : public IServiceFactory {
|
||||||
{
|
public:
|
||||||
public:
|
ServiceFactory(boost::asio::io_service &ioService, configuration::IConfiguration::Pointer configuration);
|
||||||
ServiceFactory(boost::asio::io_service& ioService, configuration::IConfiguration::Pointer configuration);
|
ServiceList create(aasdk::messenger::IMessenger::Pointer messenger) override;
|
||||||
ServiceList create(aasdk::messenger::IMessenger::Pointer messenger) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IService::Pointer createVideoService(aasdk::messenger::IMessenger::Pointer messenger);
|
IService::Pointer createBluetoothService(aasdk::messenger::IMessenger::Pointer messenger);
|
||||||
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 createInputService(aasdk::messenger::IMessenger::Pointer messenger);
|
||||||
void createAudioServices(ServiceList& serviceList, 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_;
|
void createMediaSinkServices(ServiceList &serviceList, aasdk::messenger::IMessenger::Pointer messenger);
|
||||||
configuration::IConfiguration::Pointer configuration_;
|
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 {
|
||||||
|
namespace openauto {
|
||||||
|
namespace autoapp {
|
||||||
|
namespace service {
|
||||||
|
namespace 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::channel::control::servicediscovery::notification::ServiceDiscoveryResponse &response) override;
|
||||||
|
|
||||||
|
void onChannelOpenRequest(const aap_protobuf::channel::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 <f1x/aasdk/Channel/AV/VideoServiceChannel.hpp>
|
|
||||||
#include <f1x/aasdk/Channel/AV/IVideoServiceChannelEventHandler.hpp>
|
|
||||||
#include <f1x/openauto/autoapp/Projection/IVideoOutput.hpp>
|
|
||||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
|
||||||
|
|
||||||
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_;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -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/WifiProjection/WifiProjectionservice.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 wifiprojection {
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
void start() override;
|
||||||
|
void stop() override;
|
||||||
|
void pause() override;
|
||||||
|
void resume() override;
|
||||||
|
void fillFeatures(aap_protobuf::channel::control::servicediscovery::notification::ServiceDiscoveryResponse &response) override;
|
||||||
|
|
||||||
|
void onChannelOpenRequest(const aap_protobuf::channel::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;
|
||||||
|
boost::asio::deadline_timer timer_;
|
||||||
|
boost::asio::io_service::strand strand_;
|
||||||
|
aasdk::channel::wifiprojection::WifiProjectionService::Pointer channel_;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3,8 +3,8 @@
|
|||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QStringListModel>
|
#include <QStringListModel>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <f1x/aasdk/TCP/ITCPEndpoint.hpp>
|
#include <aasdk/TCP/ITCPEndpoint.hpp>
|
||||||
#include <f1x/aasdk/TCP/ITCPWrapper.hpp>
|
#include <aasdk/TCP/ITCPWrapper.hpp>
|
||||||
#include <f1x/openauto/autoapp/Configuration/IRecentAddressesList.hpp>
|
#include <f1x/openauto/autoapp/Configuration/IRecentAddressesList.hpp>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <sys/sysinfo.h>
|
|
||||||
|
|
||||||
class QCheckBox;
|
class QCheckBox;
|
||||||
class QTimer;
|
class QTimer;
|
||||||
@ -100,7 +99,7 @@ private:
|
|||||||
void load();
|
void load();
|
||||||
void loadButtonCheckBoxes();
|
void loadButtonCheckBoxes();
|
||||||
void saveButtonCheckBoxes();
|
void saveButtonCheckBoxes();
|
||||||
void saveButtonCheckBox(const QCheckBox* checkBox, configuration::IConfiguration::ButtonCodes& buttonCodes, aasdk::proto::enums::ButtonCode::Enum buttonCode);
|
void saveButtonCheckBox(const QCheckBox* checkBox, configuration::IConfiguration::ButtonCodes& buttonCodes, aap_protobuf::service::media::sink::KeyCode buttonCode);
|
||||||
void setButtonCheckBoxes(bool value);
|
void setButtonCheckBoxes(bool value);
|
||||||
|
|
||||||
Ui::SettingsWindow* ui_;
|
Ui::SettingsWindow* ui_;
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include <QBluetoothServer>
|
#include <QBluetoothServer>
|
||||||
#include <f1x/openauto/btservice/IAndroidBluetoothServer.hpp>
|
#include <f1x/openauto/btservice/IAndroidBluetoothServer.hpp>
|
||||||
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
||||||
#include <f1x/aasdk/Messenger/Message.hpp>
|
#include <aasdk/Messenger/Message.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
{
|
{
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <f1x/aasdk/USB/AOAPDevice.hpp>
|
#include <aasdk/USB/AOAPDevice.hpp>
|
||||||
#include <f1x/aasdk/TCP/TCPEndpoint.hpp>
|
#include <aasdk/TCP/TCPEndpoint.hpp>
|
||||||
#include <f1x/openauto/autoapp/App.hpp>
|
#include <f1x/openauto/autoapp/App.hpp>
|
||||||
#include <f1x/openauto/Common/Log.hpp>
|
#include <f1x/openauto/Common/Log.hpp>
|
||||||
|
|
||||||
|
@ -60,8 +60,11 @@ const std::string Configuration::cVideoOMXLayerIndexKey = "Video.OMXLayerIndex";
|
|||||||
const std::string Configuration::cVideoMarginWidth = "Video.MarginWidth";
|
const std::string Configuration::cVideoMarginWidth = "Video.MarginWidth";
|
||||||
const std::string Configuration::cVideoMarginHeight = "Video.MarginHeight";
|
const std::string Configuration::cVideoMarginHeight = "Video.MarginHeight";
|
||||||
|
|
||||||
const std::string Configuration::cAudioMusicAudioChannelEnabled = "Audio.MusicAudioChannelEnabled";
|
const std::string Configuration::Audio::Channel::cMediaEnabled = "Audio.Channel.MediaEnabled";
|
||||||
const std::string Configuration::cAudioSpeechAudioChannelEnabled = "Audio.SpeechAudioChannelEnabled";
|
const std::string Configuration::Audio::Channel::cGuidanceEnabled = "Audio.Channel.GuidanceEnabled";
|
||||||
|
const std::string Configuration::Audio::Channel::cSystemEnabled = "Audio.Channel.SystemEnabled";
|
||||||
|
const std::string Configuration::Audio::Channel::cTelephonyEnabled = "Audio.Channel.TelephonyEnabled";
|
||||||
|
|
||||||
const std::string Configuration::cAudioOutputBackendType = "Audio.OutputBackendType";
|
const std::string Configuration::cAudioOutputBackendType = "Audio.OutputBackendType";
|
||||||
|
|
||||||
const std::string Configuration::cBluetoothAdapterTypeKey = "Bluetooth.AdapterType";
|
const std::string Configuration::cBluetoothAdapterTypeKey = "Bluetooth.AdapterType";
|
||||||
@ -120,11 +123,11 @@ void Configuration::load()
|
|||||||
showAutoPlay_ = iniConfig.get<bool>(cGeneralShowAutoPlayKey, false);
|
showAutoPlay_ = iniConfig.get<bool>(cGeneralShowAutoPlayKey, false);
|
||||||
instantPlay_ = iniConfig.get<bool>(cGeneralInstantPlayKey, false);
|
instantPlay_ = iniConfig.get<bool>(cGeneralInstantPlayKey, false);
|
||||||
|
|
||||||
videoFPS_ = static_cast<aasdk::proto::enums::VideoFPS::Enum>(iniConfig.get<uint32_t>(cVideoFPSKey,
|
videoFPS_ = static_cast<aap_protobuf::service::media::shared::message::VideoFrameRateType>(iniConfig.get<uint32_t>(cVideoFPSKey,
|
||||||
aasdk::proto::enums::VideoFPS::_30));
|
aap_protobuf::service::media::shared::message::VideoFrameRateType::VIDEO_FPS_30));
|
||||||
|
|
||||||
videoResolution_ = static_cast<aasdk::proto::enums::VideoResolution::Enum>(iniConfig.get<uint32_t>(cVideoResolutionKey,
|
videoResolution_ = static_cast<aap_protobuf::service::media::shared::message::VideoCodecResolutionType>(iniConfig.get<uint32_t>(cVideoResolutionKey,
|
||||||
aasdk::proto::enums::VideoResolution::_480p));
|
aap_protobuf::service::media::shared::message::VideoCodecResolutionType::VIDEO_800x480));
|
||||||
screenDPI_ = iniConfig.get<size_t>(cVideoScreenDPIKey, 140);
|
screenDPI_ = iniConfig.get<size_t>(cVideoScreenDPIKey, 140);
|
||||||
|
|
||||||
omxLayerIndex_ = iniConfig.get<int32_t>(cVideoOMXLayerIndexKey, 1);
|
omxLayerIndex_ = iniConfig.get<int32_t>(cVideoOMXLayerIndexKey, 1);
|
||||||
@ -138,8 +141,12 @@ void Configuration::load()
|
|||||||
static_cast<uint32_t>(BluetoothAdapterType::NONE)));
|
static_cast<uint32_t>(BluetoothAdapterType::NONE)));
|
||||||
|
|
||||||
bluetoothRemoteAdapterAddress_ = iniConfig.get<std::string>(cBluetoothRemoteAdapterAddressKey, "");
|
bluetoothRemoteAdapterAddress_ = iniConfig.get<std::string>(cBluetoothRemoteAdapterAddressKey, "");
|
||||||
musicAudioChannelEnabled_ = iniConfig.get<bool>(cAudioMusicAudioChannelEnabled, true);
|
|
||||||
speechAudiochannelEnabled_ = iniConfig.get<bool>(cAudioSpeechAudioChannelEnabled, true);
|
_audioChannelEnabledMedia = iniConfig.get<bool>(Audio::Channel::cMediaEnabled, true);
|
||||||
|
_audioChannelEnabledGuidance = iniConfig.get<bool>(Audio::Channel::cGuidanceEnabled, true);
|
||||||
|
_audioChannelEnabledSystem = iniConfig.get<bool>(Audio::Channel::cSystemEnabled, true);
|
||||||
|
_audioChannelEnabledTelephony = iniConfig.get<bool>(Audio::Channel::cTelephonyEnabled, true);
|
||||||
|
|
||||||
audioOutputBackendType_ = static_cast<AudioOutputBackendType>(iniConfig.get<uint32_t>(cAudioOutputBackendType, static_cast<uint32_t>(AudioOutputBackendType::RTAUDIO)));
|
audioOutputBackendType_ = static_cast<AudioOutputBackendType>(iniConfig.get<uint32_t>(cAudioOutputBackendType, static_cast<uint32_t>(AudioOutputBackendType::RTAUDIO)));
|
||||||
}
|
}
|
||||||
catch(const boost::property_tree::ini_parser_error& e)
|
catch(const boost::property_tree::ini_parser_error& e)
|
||||||
@ -171,8 +178,8 @@ void Configuration::reset()
|
|||||||
mp3AutoPlay_ = false;
|
mp3AutoPlay_ = false;
|
||||||
showAutoPlay_ = false;
|
showAutoPlay_ = false;
|
||||||
instantPlay_ = false;
|
instantPlay_ = false;
|
||||||
videoFPS_ = aasdk::proto::enums::VideoFPS::_30;
|
videoFPS_ = aap_protobuf::service::media::shared::message::VideoFrameRateType::VIDEO_FPS_30;
|
||||||
videoResolution_ = aasdk::proto::enums::VideoResolution::_480p;
|
videoResolution_ = aap_protobuf::service::media::shared::message::VideoCodecResolutionType::VIDEO_800x480;
|
||||||
screenDPI_ = 140;
|
screenDPI_ = 140;
|
||||||
omxLayerIndex_ = 1;
|
omxLayerIndex_ = 1;
|
||||||
videoMargins_ = QRect(0, 0, 0, 0);
|
videoMargins_ = QRect(0, 0, 0, 0);
|
||||||
@ -181,8 +188,12 @@ void Configuration::reset()
|
|||||||
buttonCodes_.clear();
|
buttonCodes_.clear();
|
||||||
bluetoothAdapterType_ = BluetoothAdapterType::NONE;
|
bluetoothAdapterType_ = BluetoothAdapterType::NONE;
|
||||||
bluetoothRemoteAdapterAddress_ = "";
|
bluetoothRemoteAdapterAddress_ = "";
|
||||||
musicAudioChannelEnabled_ = true;
|
|
||||||
speechAudiochannelEnabled_ = true;
|
_audioChannelEnabledMedia = true;
|
||||||
|
_audioChannelEnabledGuidance = true;
|
||||||
|
_audioChannelEnabledSystem = true;
|
||||||
|
_audioChannelEnabledTelephony = true;
|
||||||
|
|
||||||
audioOutputBackendType_ = AudioOutputBackendType::QT;
|
audioOutputBackendType_ = AudioOutputBackendType::QT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,9 +234,12 @@ void Configuration::save()
|
|||||||
iniConfig.put<uint32_t>(cBluetoothAdapterTypeKey, static_cast<uint32_t>(bluetoothAdapterType_));
|
iniConfig.put<uint32_t>(cBluetoothAdapterTypeKey, static_cast<uint32_t>(bluetoothAdapterType_));
|
||||||
iniConfig.put<std::string>(cBluetoothRemoteAdapterAddressKey, bluetoothRemoteAdapterAddress_);
|
iniConfig.put<std::string>(cBluetoothRemoteAdapterAddressKey, bluetoothRemoteAdapterAddress_);
|
||||||
|
|
||||||
iniConfig.put<bool>(cAudioMusicAudioChannelEnabled, musicAudioChannelEnabled_);
|
iniConfig.put<bool>(Audio::Channel::cMediaEnabled, _audioChannelEnabledMedia);
|
||||||
iniConfig.put<bool>(cAudioSpeechAudioChannelEnabled, speechAudiochannelEnabled_);
|
iniConfig.put<bool>(Audio::Channel::cGuidanceEnabled, _audioChannelEnabledGuidance);
|
||||||
iniConfig.put<uint32_t>(cAudioOutputBackendType, static_cast<uint32_t>(audioOutputBackendType_));
|
iniConfig.put<bool>(Audio::Channel::cSystemEnabled, _audioChannelEnabledSystem);
|
||||||
|
iniConfig.put<bool>(Audio::Channel::cTelephonyEnabled, _audioChannelEnabledTelephony);
|
||||||
|
|
||||||
|
iniConfig.put<uint32_t>(cAudioOutputBackendType, static_cast<uint32_t>(audioOutputBackendType_));
|
||||||
boost::property_tree::ini_parser::write_ini(cConfigFileName, iniConfig);
|
boost::property_tree::ini_parser::write_ini(cConfigFileName, iniConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -428,22 +442,22 @@ bool Configuration::instantPlay() const
|
|||||||
return instantPlay_;
|
return instantPlay_;
|
||||||
}
|
}
|
||||||
|
|
||||||
aasdk::proto::enums::VideoFPS::Enum Configuration::getVideoFPS() const
|
aap_protobuf::service::media::shared::message::VideoFrameRateType Configuration::getVideoFPS() const
|
||||||
{
|
{
|
||||||
return videoFPS_;
|
return videoFPS_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Configuration::setVideoFPS(aasdk::proto::enums::VideoFPS::Enum value)
|
void Configuration::setVideoFPS(aap_protobuf::service::media::shared::message::VideoFrameRateType value)
|
||||||
{
|
{
|
||||||
videoFPS_ = value;
|
videoFPS_ = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
aasdk::proto::enums::VideoResolution::Enum Configuration::getVideoResolution() const
|
aap_protobuf::service::media::shared::message::VideoCodecResolutionType Configuration::getVideoResolution() const
|
||||||
{
|
{
|
||||||
return videoResolution_;
|
return videoResolution_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Configuration::setVideoResolution(aasdk::proto::enums::VideoResolution::Enum value)
|
void Configuration::setVideoResolution(aap_protobuf::service::media::shared::message::VideoCodecResolutionType value)
|
||||||
{
|
{
|
||||||
videoResolution_ = value;
|
videoResolution_ = value;
|
||||||
}
|
}
|
||||||
@ -530,24 +544,44 @@ void Configuration::setBluetoothRemoteAdapterAddress(const std::string& value)
|
|||||||
|
|
||||||
bool Configuration::musicAudioChannelEnabled() const
|
bool Configuration::musicAudioChannelEnabled() const
|
||||||
{
|
{
|
||||||
return musicAudioChannelEnabled_;
|
return _audioChannelEnabledMedia;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Configuration::setMusicAudioChannelEnabled(bool value)
|
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
|
AudioOutputBackendType Configuration::getAudioOutputBackendType() const
|
||||||
{
|
{
|
||||||
return audioOutputBackendType_;
|
return audioOutputBackendType_;
|
||||||
@ -683,26 +717,26 @@ QString Configuration::readFileContent(QString fileName) const
|
|||||||
|
|
||||||
void Configuration::readButtonCodes(boost::property_tree::ptree& iniConfig)
|
void Configuration::readButtonCodes(boost::property_tree::ptree& iniConfig)
|
||||||
{
|
{
|
||||||
this->insertButtonCode(iniConfig, cInputPlayButtonKey, aasdk::proto::enums::ButtonCode::PLAY);
|
this->insertButtonCode(iniConfig, cInputPlayButtonKey, aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_PLAY);
|
||||||
this->insertButtonCode(iniConfig, cInputPauseButtonKey, aasdk::proto::enums::ButtonCode::PAUSE);
|
this->insertButtonCode(iniConfig, cInputPauseButtonKey, aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_PAUSE);
|
||||||
this->insertButtonCode(iniConfig, cInputTogglePlayButtonKey, aasdk::proto::enums::ButtonCode::TOGGLE_PLAY);
|
this->insertButtonCode(iniConfig, cInputTogglePlayButtonKey, aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_PLAY_PAUSE);
|
||||||
this->insertButtonCode(iniConfig, cInputNextTrackButtonKey, aasdk::proto::enums::ButtonCode::NEXT);
|
this->insertButtonCode(iniConfig, cInputNextTrackButtonKey, aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_NEXT);
|
||||||
this->insertButtonCode(iniConfig, cInputPreviousTrackButtonKey, aasdk::proto::enums::ButtonCode::PREV);
|
this->insertButtonCode(iniConfig, cInputPreviousTrackButtonKey, aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_PREVIOUS);
|
||||||
this->insertButtonCode(iniConfig, cInputHomeButtonKey, aasdk::proto::enums::ButtonCode::HOME);
|
this->insertButtonCode(iniConfig, cInputHomeButtonKey, aap_protobuf::service::media::sink::KeyCode::KEYCODE_HOME);
|
||||||
this->insertButtonCode(iniConfig, cInputPhoneButtonKey, aasdk::proto::enums::ButtonCode::PHONE);
|
this->insertButtonCode(iniConfig, cInputPhoneButtonKey, aap_protobuf::service::media::sink::KeyCode::KEYCODE_CALL);
|
||||||
this->insertButtonCode(iniConfig, cInputCallEndButtonKey, aasdk::proto::enums::ButtonCode::CALL_END);
|
this->insertButtonCode(iniConfig, cInputCallEndButtonKey, aap_protobuf::service::media::sink::KeyCode::KEYCODE_ENDCALL);
|
||||||
this->insertButtonCode(iniConfig, cInputVoiceCommandButtonKey, aasdk::proto::enums::ButtonCode::MICROPHONE_1);
|
this->insertButtonCode(iniConfig, cInputVoiceCommandButtonKey, aap_protobuf::service::media::sink::KeyCode::KEYCODE_SEARCH);
|
||||||
this->insertButtonCode(iniConfig, cInputLeftButtonKey, aasdk::proto::enums::ButtonCode::LEFT);
|
this->insertButtonCode(iniConfig, cInputLeftButtonKey, aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_LEFT);
|
||||||
this->insertButtonCode(iniConfig, cInputRightButtonKey, aasdk::proto::enums::ButtonCode::RIGHT);
|
this->insertButtonCode(iniConfig, cInputRightButtonKey, aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_RIGHT);
|
||||||
this->insertButtonCode(iniConfig, cInputUpButtonKey, aasdk::proto::enums::ButtonCode::UP);
|
this->insertButtonCode(iniConfig, cInputUpButtonKey, aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_UP);
|
||||||
this->insertButtonCode(iniConfig, cInputDownButtonKey, aasdk::proto::enums::ButtonCode::DOWN);
|
this->insertButtonCode(iniConfig, cInputDownButtonKey, aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_DOWN);
|
||||||
this->insertButtonCode(iniConfig, cInputScrollWheelButtonKey, aasdk::proto::enums::ButtonCode::SCROLL_WHEEL);
|
this->insertButtonCode(iniConfig, cInputScrollWheelButtonKey, aap_protobuf::service::media::sink::KeyCode::KEYCODE_ROTARY_CONTROLLER);
|
||||||
this->insertButtonCode(iniConfig, cInputBackButtonKey, aasdk::proto::enums::ButtonCode::BACK);
|
this->insertButtonCode(iniConfig, cInputBackButtonKey, aap_protobuf::service::media::sink::KeyCode::KEYCODE_BACK);
|
||||||
this->insertButtonCode(iniConfig, cInputEnterButtonKey, aasdk::proto::enums::ButtonCode::ENTER);
|
this->insertButtonCode(iniConfig, cInputEnterButtonKey, aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_CENTER);
|
||||||
this->insertButtonCode(iniConfig, cInputNavButtonKey, aasdk::proto::enums::ButtonCode::NAVIGATION);
|
this->insertButtonCode(iniConfig, cInputNavButtonKey, aap_protobuf::service::media::sink::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::KeyCode buttonCode)
|
||||||
{
|
{
|
||||||
if(iniConfig.get<bool>(buttonCodeKey, false))
|
if(iniConfig.get<bool>(buttonCodeKey, false))
|
||||||
{
|
{
|
||||||
@ -712,23 +746,23 @@ void Configuration::insertButtonCode(boost::property_tree::ptree& iniConfig, con
|
|||||||
|
|
||||||
void Configuration::writeButtonCodes(boost::property_tree::ptree& iniConfig)
|
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>(cInputPlayButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_PLAY) != buttonCodes_.end());
|
||||||
iniConfig.put<bool>(cInputPauseButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::PAUSE) != buttonCodes_.end());
|
iniConfig.put<bool>(cInputPauseButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_PAUSE) != buttonCodes_.end());
|
||||||
iniConfig.put<bool>(cInputTogglePlayButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::TOGGLE_PLAY) != buttonCodes_.end());
|
iniConfig.put<bool>(cInputTogglePlayButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_PLAY_PAUSE) != buttonCodes_.end());
|
||||||
iniConfig.put<bool>(cInputNextTrackButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::NEXT) != buttonCodes_.end());
|
iniConfig.put<bool>(cInputNextTrackButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_NEXT) != buttonCodes_.end());
|
||||||
iniConfig.put<bool>(cInputPreviousTrackButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::PREV) != buttonCodes_.end());
|
iniConfig.put<bool>(cInputPreviousTrackButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_PREVIOUS) != buttonCodes_.end());
|
||||||
iniConfig.put<bool>(cInputHomeButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::HOME) != buttonCodes_.end());
|
iniConfig.put<bool>(cInputHomeButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_HOME) != buttonCodes_.end());
|
||||||
iniConfig.put<bool>(cInputPhoneButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::PHONE) != buttonCodes_.end());
|
iniConfig.put<bool>(cInputPhoneButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_CALL) != buttonCodes_.end());
|
||||||
iniConfig.put<bool>(cInputCallEndButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::CALL_END) != buttonCodes_.end());
|
iniConfig.put<bool>(cInputCallEndButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_ENDCALL) != buttonCodes_.end());
|
||||||
iniConfig.put<bool>(cInputVoiceCommandButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::MICROPHONE_1) != buttonCodes_.end());
|
iniConfig.put<bool>(cInputVoiceCommandButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_SEARCH) != buttonCodes_.end());
|
||||||
iniConfig.put<bool>(cInputLeftButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::LEFT) != buttonCodes_.end());
|
iniConfig.put<bool>(cInputLeftButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_LEFT) != buttonCodes_.end());
|
||||||
iniConfig.put<bool>(cInputRightButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::RIGHT) != buttonCodes_.end());
|
iniConfig.put<bool>(cInputRightButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_RIGHT) != buttonCodes_.end());
|
||||||
iniConfig.put<bool>(cInputUpButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::UP) != buttonCodes_.end());
|
iniConfig.put<bool>(cInputUpButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_UP) != buttonCodes_.end());
|
||||||
iniConfig.put<bool>(cInputDownButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::DOWN) != buttonCodes_.end());
|
iniConfig.put<bool>(cInputDownButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_DOWN) != buttonCodes_.end());
|
||||||
iniConfig.put<bool>(cInputScrollWheelButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::SCROLL_WHEEL) != buttonCodes_.end());
|
iniConfig.put<bool>(cInputScrollWheelButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_ROTARY_CONTROLLER) != buttonCodes_.end());
|
||||||
iniConfig.put<bool>(cInputBackButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::BACK) != buttonCodes_.end());
|
iniConfig.put<bool>(cInputBackButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_BACK) != buttonCodes_.end());
|
||||||
iniConfig.put<bool>(cInputEnterButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::ENTER) != buttonCodes_.end());
|
iniConfig.put<bool>(cInputEnterButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_CENTER) != buttonCodes_.end());
|
||||||
iniConfig.put<bool>(cInputNavButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::NAVIGATION) != buttonCodes_.end());
|
iniConfig.put<bool>(cInputNavButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_NAVIGATION) != buttonCodes_.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -83,91 +83,91 @@ bool InputDevice::eventFilter(QObject* obj, QEvent* event)
|
|||||||
bool InputDevice::handleKeyEvent(QEvent* event, QKeyEvent* key)
|
bool InputDevice::handleKeyEvent(QEvent* event, QKeyEvent* key)
|
||||||
{
|
{
|
||||||
auto eventType = event->type() == QEvent::KeyPress ? ButtonEventType::PRESS : ButtonEventType::RELEASE;
|
auto eventType = event->type() == QEvent::KeyPress ? ButtonEventType::PRESS : ButtonEventType::RELEASE;
|
||||||
aasdk::proto::enums::ButtonCode::Enum buttonCode;
|
aap_protobuf::service::media::sink::KeyCode buttonCode;
|
||||||
WheelDirection wheelDirection = WheelDirection::NONE;
|
WheelDirection wheelDirection = WheelDirection::NONE;
|
||||||
|
|
||||||
switch(key->key())
|
switch(key->key())
|
||||||
{
|
{
|
||||||
case Qt::Key_Return:
|
case Qt::Key_Return:
|
||||||
case Qt::Key_Enter:
|
case Qt::Key_Enter:
|
||||||
buttonCode = aasdk::proto::enums::ButtonCode::ENTER;
|
buttonCode = aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_CENTER;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_Left:
|
case Qt::Key_Left:
|
||||||
buttonCode = aasdk::proto::enums::ButtonCode::LEFT;
|
buttonCode = aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_LEFT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_Right:
|
case Qt::Key_Right:
|
||||||
buttonCode = aasdk::proto::enums::ButtonCode::RIGHT;
|
buttonCode = aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_RIGHT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_Up:
|
case Qt::Key_Up:
|
||||||
buttonCode = aasdk::proto::enums::ButtonCode::UP;
|
buttonCode = aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_UP;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_Down:
|
case Qt::Key_Down:
|
||||||
buttonCode = aasdk::proto::enums::ButtonCode::DOWN;
|
buttonCode = aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_DOWN;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_Escape:
|
case Qt::Key_Escape:
|
||||||
buttonCode = aasdk::proto::enums::ButtonCode::BACK;
|
buttonCode = aap_protobuf::service::media::sink::KeyCode::KEYCODE_BACK;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_H:
|
case Qt::Key_H:
|
||||||
buttonCode = aasdk::proto::enums::ButtonCode::HOME;
|
buttonCode = aap_protobuf::service::media::sink::KeyCode::KEYCODE_HOME;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_P:
|
case Qt::Key_P:
|
||||||
buttonCode = aasdk::proto::enums::ButtonCode::PHONE;
|
buttonCode = aap_protobuf::service::media::sink::KeyCode::KEYCODE_CALL;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_O:
|
case Qt::Key_O:
|
||||||
buttonCode = aasdk::proto::enums::ButtonCode::CALL_END;
|
buttonCode = aap_protobuf::service::media::sink::KeyCode::KEYCODE_ENDCALL;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_MediaPlay:
|
case Qt::Key_MediaPlay:
|
||||||
case Qt::Key_X:
|
case Qt::Key_X:
|
||||||
buttonCode = aasdk::proto::enums::ButtonCode::PLAY;
|
buttonCode = aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_PLAY;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_MediaPause:
|
case Qt::Key_MediaPause:
|
||||||
case Qt::Key_C:
|
case Qt::Key_C:
|
||||||
buttonCode = aasdk::proto::enums::ButtonCode::PAUSE;
|
buttonCode = aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_PAUSE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_MediaPrevious:
|
case Qt::Key_MediaPrevious:
|
||||||
case Qt::Key_V:
|
case Qt::Key_V:
|
||||||
buttonCode = aasdk::proto::enums::ButtonCode::PREV;
|
buttonCode = aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_PREVIOUS;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_MediaTogglePlayPause:
|
case Qt::Key_MediaTogglePlayPause:
|
||||||
case Qt::Key_B:
|
case Qt::Key_B:
|
||||||
buttonCode = aasdk::proto::enums::ButtonCode::TOGGLE_PLAY;
|
buttonCode = aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_PLAY_PAUSE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_MediaNext:
|
case Qt::Key_MediaNext:
|
||||||
case Qt::Key_N:
|
case Qt::Key_N:
|
||||||
buttonCode = aasdk::proto::enums::ButtonCode::NEXT;
|
buttonCode = aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_NEXT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_M:
|
case Qt::Key_M:
|
||||||
buttonCode = aasdk::proto::enums::ButtonCode::MICROPHONE_1;
|
buttonCode = aap_protobuf::service::media::sink::KeyCode::KEYCODE_SEARCH;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_1:
|
case Qt::Key_1:
|
||||||
wheelDirection = WheelDirection::LEFT;
|
wheelDirection = WheelDirection::LEFT;
|
||||||
eventType = ButtonEventType::NONE;
|
eventType = ButtonEventType::NONE;
|
||||||
buttonCode = aasdk::proto::enums::ButtonCode::SCROLL_WHEEL;
|
buttonCode = aap_protobuf::service::media::sink::KeyCode::KEYCODE_ROTARY_CONTROLLER;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_2:
|
case Qt::Key_2:
|
||||||
wheelDirection = WheelDirection::RIGHT;
|
wheelDirection = WheelDirection::RIGHT;
|
||||||
eventType = ButtonEventType::NONE;
|
eventType = ButtonEventType::NONE;
|
||||||
buttonCode = aasdk::proto::enums::ButtonCode::SCROLL_WHEEL;
|
buttonCode = aap_protobuf::service::media::sink::KeyCode::KEYCODE_ROTARY_CONTROLLER;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_F:
|
case Qt::Key_F:
|
||||||
buttonCode = aasdk::proto::enums::ButtonCode::NAVIGATION;
|
buttonCode = aap_protobuf::service::media::sink::KeyCode::KEYCODE_NAVIGATION;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -177,7 +177,7 @@ bool InputDevice::handleKeyEvent(QEvent* event, QKeyEvent* key)
|
|||||||
const auto& buttonCodes = this->getSupportedButtonCodes();
|
const auto& buttonCodes = this->getSupportedButtonCodes();
|
||||||
if(std::find(buttonCodes.begin(), buttonCodes.end(), buttonCode) != buttonCodes.end())
|
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::KeyCode::KEYCODE_ROTARY_CONTROLLER || event->type() == QEvent::KeyRelease)
|
||||||
{
|
{
|
||||||
eventHandler_->onButtonEvent({eventType, wheelDirection, buttonCode});
|
eventHandler_->onButtonEvent({eventType, wheelDirection, buttonCode});
|
||||||
}
|
}
|
||||||
@ -193,18 +193,18 @@ bool InputDevice::handleTouchEvent(QEvent* event)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
aasdk::proto::enums::TouchAction::Enum type;
|
aap_protobuf::service::input::message::TouchAction type;
|
||||||
|
|
||||||
switch(event->type())
|
switch(event->type())
|
||||||
{
|
{
|
||||||
case QEvent::MouseButtonPress:
|
case QEvent::MouseButtonPress:
|
||||||
type = aasdk::proto::enums::TouchAction::PRESS;
|
type = aap_protobuf::service::input::message::TouchAction::ACTION_DOWN;
|
||||||
break;
|
break;
|
||||||
case QEvent::MouseButtonRelease:
|
case QEvent::MouseButtonRelease:
|
||||||
type = aasdk::proto::enums::TouchAction::RELEASE;
|
type = aap_protobuf::service::input::message::TouchAction::ACTION_UP;
|
||||||
break;
|
break;
|
||||||
case QEvent::MouseMove:
|
case QEvent::MouseMove:
|
||||||
type = aasdk::proto::enums::TouchAction::DRAG;
|
type = aap_protobuf::service::input::message::TouchAction::ACTION_MOVED;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return true;
|
return true;
|
||||||
|
@ -23,7 +23,7 @@ extern "C"
|
|||||||
#include <bcm_host.h>
|
#include <bcm_host.h>
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <f1x/aasdk/Common/Data.hpp>
|
#include <aasdk/Common/Data.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/OMXVideoOutput.hpp>
|
#include <f1x/openauto/autoapp/Projection/OMXVideoOutput.hpp>
|
||||||
#include <f1x/openauto/Common/Log.hpp>
|
#include <f1x/openauto/Common/Log.hpp>
|
||||||
|
|
||||||
|
@ -33,9 +33,15 @@ RtAudioOutput::RtAudioOutput(uint32_t channelCount, uint32_t sampleSize, uint32_
|
|||||||
, sampleSize_(sampleSize)
|
, sampleSize_(sampleSize)
|
||||||
, sampleRate_(sampleRate)
|
, sampleRate_(sampleRate)
|
||||||
{
|
{
|
||||||
std::vector<RtAudio::Api> apis;
|
|
||||||
RtAudio::getCompiledApi(apis);
|
std::vector<RtAudio::Api> apis;
|
||||||
dac_ = std::find(apis.begin(), apis.end(), RtAudio::LINUX_PULSE) == apis.end() ? std::make_unique<RtAudio>() : std::make_unique<RtAudio>(RtAudio::LINUX_PULSE);
|
RtAudio::getCompiledApi(apis);
|
||||||
|
dac_ = std::find(apis.begin(), apis.end(), RtAudio::LINUX_PULSE) == apis.end() ? std::make_unique<RtAudio>() : std::make_unique<RtAudio>(RtAudio::LINUX_PULSE);
|
||||||
|
|
||||||
|
// Set the error callback
|
||||||
|
dac_->setErrorCallback([](RtAudioErrorType type, const std::string& errorText) {
|
||||||
|
OPENAUTO_LOG(error) << "[RtAudioOutput] " << errorText;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RtAudioOutput::open()
|
bool RtAudioOutput::open()
|
||||||
@ -54,13 +60,19 @@ bool RtAudioOutput::open()
|
|||||||
RtAudio::StreamOptions streamOptions;
|
RtAudio::StreamOptions streamOptions;
|
||||||
streamOptions.flags = RTAUDIO_MINIMIZE_LATENCY | RTAUDIO_SCHEDULE_REALTIME;
|
streamOptions.flags = RTAUDIO_MINIMIZE_LATENCY | RTAUDIO_SCHEDULE_REALTIME;
|
||||||
uint32_t bufferFrames = sampleRate_ == 16000 ? 1024 : 2048; //according to the observation of audio packets
|
uint32_t bufferFrames = sampleRate_ == 16000 ? 1024 : 2048; //according to the observation of audio packets
|
||||||
|
auto result = dac_->openStream(¶meters, nullptr, RTAUDIO_SINT16, sampleRate_, &bufferFrames, &RtAudioOutput::audioBufferReadHandler, static_cast<void*>(this), &streamOptions);
|
||||||
dac_->openStream(¶meters, nullptr, RTAUDIO_SINT16, sampleRate_, &bufferFrames, &RtAudioOutput::audioBufferReadHandler, static_cast<void*>(this), &streamOptions);
|
dac_->openStream(¶meters, nullptr, RTAUDIO_SINT16, sampleRate_, &bufferFrames, &RtAudioOutput::audioBufferReadHandler, static_cast<void*>(this), &streamOptions);
|
||||||
OPENAUTO_LOG(info) << "[RtAudioOutput] Sample Rate: " << sampleRate_;
|
if (result == RtAudioErrorType::RTAUDIO_NO_ERROR) {
|
||||||
return audioBuffer_.open(QIODevice::ReadWrite);
|
OPENAUTO_LOG(info) << "[RtAudioOutput] Sample Rate: " << sampleRate_;
|
||||||
|
return audioBuffer_.open(QIODevice::ReadWrite);
|
||||||
|
} else {
|
||||||
|
// Log the error using the callback or handle it here directly
|
||||||
|
OPENAUTO_LOG(error) << "[RtAudioOutput] Error opening stream: ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch(const RtAudioError& e)
|
catch(const std::exception& e)
|
||||||
{
|
{
|
||||||
OPENAUTO_LOG(error) << "[RtAudioOutput] Failed to open audio output, what: " << e.what();
|
OPENAUTO_LOG(error) << "[RtAudioOutput] Exception: " << e.what();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -86,9 +98,10 @@ void RtAudioOutput::start()
|
|||||||
{
|
{
|
||||||
dac_->startStream();
|
dac_->startStream();
|
||||||
}
|
}
|
||||||
catch(const RtAudioError& e)
|
catch(const RtAudioErrorType& e)
|
||||||
{
|
{
|
||||||
OPENAUTO_LOG(error) << "[RtAudioOutput] Failed to start audio output, what: " << e.what();
|
// TODO: What's the new RtAudio Error?
|
||||||
|
//OPENAUTO_LOG(error) << "[RtAudioOutput] Failed to start audio output, what: " << e.what();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -133,9 +146,10 @@ void RtAudioOutput::doSuspend()
|
|||||||
{
|
{
|
||||||
dac_->stopStream();
|
dac_->stopStream();
|
||||||
}
|
}
|
||||||
catch(const RtAudioError& e)
|
catch(const RtAudioErrorType& e)
|
||||||
{
|
{
|
||||||
OPENAUTO_LOG(error) << "[RtAudioOutput] Failed to suspend audio output, what: " << e.what();
|
// TODO: What's the new RtAudio Error?
|
||||||
|
//OPENAUTO_LOG(error) << "[RtAudioOutput] Failed to suspend audio output, what: " << e.what();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,12 +33,12 @@ VideoOutput::VideoOutput(configuration::IConfiguration::Pointer configuration)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
aasdk::proto::enums::VideoFPS::Enum VideoOutput::getVideoFPS() const
|
aap_protobuf::service::media::shared::message::VideoFrameRateType VideoOutput::getVideoFPS() const
|
||||||
{
|
{
|
||||||
return configuration_->getVideoFPS();
|
return configuration_->getVideoFPS();
|
||||||
}
|
}
|
||||||
|
|
||||||
aasdk::proto::enums::VideoResolution::Enum VideoOutput::getVideoResolution() const
|
aap_protobuf::service::media::shared::message::VideoCodecResolutionType VideoOutput::getVideoResolution() const
|
||||||
{
|
{
|
||||||
return configuration_->getVideoResolution();
|
return configuration_->getVideoResolution();
|
||||||
}
|
}
|
||||||
|
@ -16,10 +16,64 @@
|
|||||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <f1x/aasdk/Channel/Control/ControlServiceChannel.hpp>
|
#include <aap_protobuf/connection/WirelessTcpConfiguration.pb.h>
|
||||||
|
#include <aap_protobuf/connection/PingConfiguration.pb.h>
|
||||||
|
#include <aap_protobuf/connection/ConnectionConfiguration.pb.h>
|
||||||
|
#include <aap_protobuf/channel/control/focus/audio/event/AudioFocusRequestType.pb.h>
|
||||||
|
#include <aap_protobuf/channel/control/focus/audio/notification/AudioFocusStateType.pb.h>
|
||||||
|
#include <aap_protobuf/channel/control/focus/navigation/shared/NavFocusType.pb.h>
|
||||||
|
#include <aasdk/Channel/Control/ControlServiceChannel.hpp>
|
||||||
#include <f1x/openauto/autoapp/Service/AndroidAutoEntity.hpp>
|
#include <f1x/openauto/autoapp/Service/AndroidAutoEntity.hpp>
|
||||||
#include <f1x/openauto/Common/Log.hpp>
|
#include <f1x/openauto/Common/Log.hpp>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* HU > MD Version Request
|
||||||
|
* HU < MD ServiceDiscoveryRequest
|
||||||
|
* HU > MD Car MetaData (Make, Model, year etc)
|
||||||
|
* HU < MD when Video Projection starts, it MUST be shown without User Ineraction
|
||||||
|
* HU < MD Prompt Use to Enable and Pair with Car
|
||||||
|
* HU < MD Request Video Focus for Projection (HU Grant)
|
||||||
|
*
|
||||||
|
* AAP neds Bluetooth HFP for Telephone
|
||||||
|
*
|
||||||
|
* HU > MD Bluetooth Announcement (HU MAC Address, Supported Pairing Methods)
|
||||||
|
* HU < MD Bluetooth Pairing Request
|
||||||
|
* HU > MD Bluetoth Pairing Response
|
||||||
|
*
|
||||||
|
* AfterPairing, HU can request the Bluetooth PhoneBookAccessProtocol. Sensible UI.
|
||||||
|
*
|
||||||
|
* HU < MD connect to Bluetooth HFP
|
||||||
|
* HU Suppress BAP or MAP while AAP connected.
|
||||||
|
* A2DP should be treated by OEM as another such such as a USB stick or radio. If the user plays music via AA, HU should grant request from AA to change focus to AA. HU manages connectivity.
|
||||||
|
* MD connects to HU and routes call over Bluetooth (non Bluetooth call)
|
||||||
|
* MD connects Blueooth call and display projection mode
|
||||||
|
* MD on call to HFP device - MD continues call, disconnects from other HFP and connects to HFP on Vehicle.
|
||||||
|
* AA only uses HFP, hhowever HU may use MAP, PBAP, PAN and RSAP
|
||||||
|
* MD will reconnect when required.
|
||||||
|
*
|
||||||
|
* Video
|
||||||
|
* HU < MD - During Service Discovery, MD requests Video Configs supported
|
||||||
|
* HU > MD sends Config Message with Prioritised indices for Video Conffigurations
|
||||||
|
* HU < MD MD selects config
|
||||||
|
* HU < MD sends start message
|
||||||
|
* HU < MD sends focus request
|
||||||
|
* HU > MD sends focus granted (unless unsafe - ie reverse camera etc)
|
||||||
|
* HU < MD Audio Focus Requests when MD wants to play.
|
||||||
|
* HU > MD Audio Focus Navigations (can be unsolicited or responses to requests)
|
||||||
|
* HU < MD VoiceSessionRequestNotification with VOICE_SESSION_START, HU should stop all sounds. MD will request GAIN or GAIN_TRANS to play beeps/tones and ASR response.
|
||||||
|
* Nav Focus for onboard navigation.
|
||||||
|
* UI System Sounds does not require audio focus as sounds should be played ASAP. System Stream is optionals (not required to support).
|
||||||
|
* HU should wait to receive two frames of audio before starting playback to minimise buffer underruns.
|
||||||
|
* AA Latency types supported - Audio Setup - max 500ms, Audio Output max 50ms.
|
||||||
|
* HU > MD Navigation Focus Notification specified with NF is Phone or Car.
|
||||||
|
* HU < MD Navigation Focus Request
|
||||||
|
* "For vehicles that support next turn information in the instrument cluster, the HU can subscribe to next turn updates from the MD navigation engine." (NExt Turn etc)
|
||||||
|
* same for Media Playback Status
|
||||||
|
* Radio - Allows Control of Radio from Within AA.
|
||||||
|
* Vehicle IDs SHOULD have at least 64 bits
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
{
|
{
|
||||||
namespace openauto
|
namespace openauto
|
||||||
@ -113,13 +167,13 @@ void AndroidAutoEntity::resume()
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidAutoEntity::onVersionResponse(uint16_t majorCode, uint16_t minorCode, aasdk::proto::enums::VersionResponseStatus::Enum status)
|
void AndroidAutoEntity::onVersionResponse(uint16_t majorCode, uint16_t minorCode, aap_protobuf::shared::MessageStatus status)
|
||||||
{
|
{
|
||||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] version response, version: " << majorCode
|
OPENAUTO_LOG(info) << "[AndroidAutoEntity] version response, version: " << majorCode
|
||||||
<< "." << minorCode
|
<< "." << minorCode
|
||||||
<< ", status: " << status;
|
<< ", status: " << status;
|
||||||
|
|
||||||
if(status == aasdk::proto::enums::VersionResponseStatus::MISMATCH)
|
if(status == aap_protobuf::shared::MessageStatus::STATUS_NO_COMPATIBLE_VERSION)
|
||||||
{
|
{
|
||||||
OPENAUTO_LOG(error) << "[AndroidAutoEntity] version mismatch.";
|
OPENAUTO_LOG(error) << "[AndroidAutoEntity] version mismatch.";
|
||||||
this->triggerQuit();
|
this->triggerQuit();
|
||||||
@ -164,8 +218,8 @@ void AndroidAutoEntity::onHandshake(const aasdk::common::DataConstBuffer& payloa
|
|||||||
{
|
{
|
||||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] Auth completed.";
|
OPENAUTO_LOG(info) << "[AndroidAutoEntity] Auth completed.";
|
||||||
|
|
||||||
aasdk::proto::messages::AuthCompleteIndication authCompleteIndication;
|
aap_protobuf::channel::control::auth::AuthResponse authCompleteIndication;
|
||||||
authCompleteIndication.set_status(aasdk::proto::enums::Status::OK);
|
authCompleteIndication.set_status(aap_protobuf::shared::MessageStatus::STATUS_SUCCESS);
|
||||||
|
|
||||||
auto authCompletePromise = aasdk::channel::SendPromise::defer(strand_);
|
auto authCompletePromise = aasdk::channel::SendPromise::defer(strand_);
|
||||||
authCompletePromise->then([]() {}, std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
authCompletePromise->then([]() {}, std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||||
@ -180,24 +234,47 @@ void AndroidAutoEntity::onHandshake(const aasdk::common::DataConstBuffer& payloa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidAutoEntity::onServiceDiscoveryRequest(const aasdk::proto::messages::ServiceDiscoveryRequest& request)
|
void AndroidAutoEntity::onServiceDiscoveryRequest(const aap_protobuf::channel::control::servicediscovery::event::ServiceDiscoveryRequest& request)
|
||||||
{
|
{
|
||||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] Discovery request, device name: " << request.device_name()
|
OPENAUTO_LOG(info) << "[AndroidAutoEntity] Discovery request, device name: " << request.device_name()
|
||||||
<< ", brand: " << request.device_brand();
|
<< ", brand: " << request.label_text();
|
||||||
|
|
||||||
aasdk::proto::messages::ServiceDiscoveryResponse serviceDiscoveryResponse;
|
/*
|
||||||
|
aap_protobuf::connection::PingConfiguration pingConfiguration;
|
||||||
|
pingConfiguration.set_high_latency_threshold_ms();
|
||||||
|
pingConfiguration.set_interval_ms();
|
||||||
|
pingConfiguration.set_timeout_ms();
|
||||||
|
pingConfiguration.set_tracked_ping_count();
|
||||||
|
|
||||||
|
aap_protobuf::connection::WirelessTcpConfiguration wirelessTcpConfiguration;
|
||||||
|
wirelessTcpConfiguration.set_socket_read_timeout_ms();
|
||||||
|
wirelessTcpConfiguration.set_socket_receive_buffer_size_kb();
|
||||||
|
wirelessTcpConfiguration.set_socket_send_buffer_size_kb();
|
||||||
|
|
||||||
|
aap_protobuf::connection::ConnectionConfiguration connectionConfiguration;
|
||||||
|
connectionConfiguration.set_allocated_ping_configuration();
|
||||||
|
connectionConfiguration.set_allocated_wireless_tcp_configuration();*/
|
||||||
|
|
||||||
|
aap_protobuf::channel::control::servicediscovery::notification::HeadUnitInfo headUnitInfo;
|
||||||
|
headUnitInfo.set_make("CubeOne");
|
||||||
|
headUnitInfo.set_model("Journey");
|
||||||
|
headUnitInfo.set_year("2024");
|
||||||
|
headUnitInfo.set_vehicle_id("2009");
|
||||||
|
headUnitInfo.set_head_unit_make("CubeOne");
|
||||||
|
headUnitInfo.set_head_unit_model("Journey");
|
||||||
|
headUnitInfo.set_head_unit_software_build("2024.10.15");
|
||||||
|
headUnitInfo.set_head_unit_software_version("1");
|
||||||
|
|
||||||
|
aap_protobuf::channel::control::servicediscovery::notification::ServiceDiscoveryResponse serviceDiscoveryResponse;
|
||||||
serviceDiscoveryResponse.mutable_channels()->Reserve(256);
|
serviceDiscoveryResponse.mutable_channels()->Reserve(256);
|
||||||
serviceDiscoveryResponse.set_head_unit_name("Crankshaft-NG");
|
|
||||||
serviceDiscoveryResponse.set_car_model("Universal");
|
//serviceDiscoveryResponse.set_headunit_sw_build("2024.10.15");
|
||||||
serviceDiscoveryResponse.set_car_year("2018");
|
//serviceDiscoveryResponse.set_headunit_sw_version("1");
|
||||||
serviceDiscoveryResponse.set_car_serial("20180301");
|
serviceDiscoveryResponse.set_display_name("JourneyOS");
|
||||||
serviceDiscoveryResponse.set_left_hand_drive_vehicle(configuration_->getHandednessOfTrafficType() == configuration::HandednessOfTrafficType::LEFT_HAND_DRIVE);
|
|
||||||
serviceDiscoveryResponse.set_headunit_manufacturer("f1x");
|
serviceDiscoveryResponse.set_allocated_headunit_info(&headUnitInfo);
|
||||||
serviceDiscoveryResponse.set_headunit_model("Crankshaft-NG Autoapp");
|
|
||||||
serviceDiscoveryResponse.set_sw_build("1");
|
//serviceDiscoveryResponse.set_can_play_native_media_during_vr(false);
|
||||||
serviceDiscoveryResponse.set_sw_version("1.0");
|
|
||||||
serviceDiscoveryResponse.set_can_play_native_media_during_vr(false);
|
|
||||||
serviceDiscoveryResponse.set_hide_clock(!configuration_->showClock());
|
|
||||||
|
|
||||||
std::for_each(serviceList_.begin(), serviceList_.end(), std::bind(&IService::fillFeatures, std::placeholders::_1, std::ref(serviceDiscoveryResponse)));
|
std::for_each(serviceList_.begin(), serviceList_.end(), std::bind(&IService::fillFeatures, std::placeholders::_1, std::ref(serviceDiscoveryResponse)));
|
||||||
|
|
||||||
@ -207,17 +284,18 @@ void AndroidAutoEntity::onServiceDiscoveryRequest(const aasdk::proto::messages::
|
|||||||
controlServiceChannel_->receive(this->shared_from_this());
|
controlServiceChannel_->receive(this->shared_from_this());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidAutoEntity::onAudioFocusRequest(const aasdk::proto::messages::AudioFocusRequest& request)
|
void AndroidAutoEntity::onAudioFocusRequest(const aap_protobuf::channel::control::focus::audio::event::AudioFocusRequest& request)
|
||||||
{
|
{
|
||||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] requested audio focus, type: " << request.audio_focus_type();
|
OPENAUTO_LOG(info) << "[AndroidAutoEntity] requested audio focus, type: " << request.audio_focus_type();
|
||||||
|
|
||||||
aasdk::proto::enums::AudioFocusState::Enum audioFocusState =
|
aap_protobuf::channel::control::focus::audio::notification::AudioFocusStateType audioFocusState =
|
||||||
request.audio_focus_type() == aasdk::proto::enums::AudioFocusType::RELEASE ? aasdk::proto::enums::AudioFocusState::LOSS
|
request.audio_focus_type() == aap_protobuf::channel::control::focus::audio::event::AudioFocusRequestType::AUDIO_FOCUS_RELEASE
|
||||||
: aasdk::proto::enums::AudioFocusState::GAIN;
|
? aap_protobuf::channel::control::focus::audio::notification::AudioFocusStateType::AUDIO_FOCUS_STATE_LOSS
|
||||||
|
: aap_protobuf::channel::control::focus::audio::notification::AudioFocusStateType::AUDIO_FOCUS_STATE_GAIN;
|
||||||
|
|
||||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] audio focus state: " << audioFocusState;
|
OPENAUTO_LOG(info) << "[AndroidAutoEntity] audio focus state: " << audioFocusState;
|
||||||
|
|
||||||
aasdk::proto::messages::AudioFocusResponse response;
|
aap_protobuf::channel::control::focus::audio::notification::AudioFocusNotification response;
|
||||||
response.set_audio_focus_state(audioFocusState);
|
response.set_audio_focus_state(audioFocusState);
|
||||||
|
|
||||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||||
@ -226,11 +304,11 @@ void AndroidAutoEntity::onAudioFocusRequest(const aasdk::proto::messages::AudioF
|
|||||||
controlServiceChannel_->receive(this->shared_from_this());
|
controlServiceChannel_->receive(this->shared_from_this());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidAutoEntity::onShutdownRequest(const aasdk::proto::messages::ShutdownRequest& request)
|
void AndroidAutoEntity::onByeByeRequest(const aap_protobuf::channel::control::byebye::event::ByeByeRequest& request)
|
||||||
{
|
{
|
||||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] Shutdown request, reason: " << request.reason();
|
OPENAUTO_LOG(info) << "[AndroidAutoEntity] Shutdown request, reason: " << request.reason();
|
||||||
|
|
||||||
aasdk::proto::messages::ShutdownResponse response;
|
aap_protobuf::channel::control::byebye::notification::ByeByeResponse response;
|
||||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||||
promise->then(std::bind(&AndroidAutoEntity::triggerQuit, this->shared_from_this()),
|
promise->then(std::bind(&AndroidAutoEntity::triggerQuit, this->shared_from_this()),
|
||||||
std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||||
@ -238,18 +316,18 @@ void AndroidAutoEntity::onShutdownRequest(const aasdk::proto::messages::Shutdown
|
|||||||
controlServiceChannel_->sendShutdownResponse(response, std::move(promise));
|
controlServiceChannel_->sendShutdownResponse(response, std::move(promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidAutoEntity::onShutdownResponse(const aasdk::proto::messages::ShutdownResponse&)
|
void AndroidAutoEntity::onByeByeResponse(const aap_protobuf::channel::control::byebye::notification::ByeByeResponse& response)
|
||||||
{
|
{
|
||||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] Shutdown response ";
|
OPENAUTO_LOG(info) << "[AndroidAutoEntity] Shutdown response ";
|
||||||
this->triggerQuit();
|
this->triggerQuit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidAutoEntity::onNavigationFocusRequest(const aasdk::proto::messages::NavigationFocusRequest& request)
|
void AndroidAutoEntity::onNavigationFocusRequest(const aap_protobuf::channel::control::focus::navigation::event::NavFocusRequestNotification& request)
|
||||||
{
|
{
|
||||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] navigation focus request, type: " << request.type();
|
OPENAUTO_LOG(info) << "[AndroidAutoEntity] navigation focus request, type: " << request.focus_type();
|
||||||
|
|
||||||
aasdk::proto::messages::NavigationFocusResponse response;
|
aap_protobuf::channel::control::focus::navigation::notification::NavFocusNotification response;
|
||||||
response.set_type(2);
|
response.set_focus_type(aap_protobuf::channel::control::focus::navigation::shared::NavFocusType::NAV_FOCUS_PROJECTED);
|
||||||
|
|
||||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||||
promise->then([]() {}, std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
promise->then([]() {}, std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||||
@ -257,7 +335,17 @@ void AndroidAutoEntity::onNavigationFocusRequest(const aasdk::proto::messages::N
|
|||||||
controlServiceChannel_->receive(this->shared_from_this());
|
controlServiceChannel_->receive(this->shared_from_this());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidAutoEntity::onPingResponse(const aasdk::proto::messages::PingResponse& response)
|
void onVoiceSessionRequest(const aap_protobuf::channel::control::voice::VoiceSessionNotification &request) {
|
||||||
|
// TODO: FIXME
|
||||||
|
}
|
||||||
|
void AndroidAutoEntity::onPingRequest(const aap_protobuf::channel::control::ping::PingRequest& request)
|
||||||
|
{
|
||||||
|
OPENAUTO_LOG(info) << "[AndroidAutoEntity] Ping request, timestamp: " << request.timestamp();
|
||||||
|
//pinger_->ping();
|
||||||
|
//controlServiceChannel_->receive(this->shared_from_this());
|
||||||
|
}
|
||||||
|
|
||||||
|
void AndroidAutoEntity::onPingResponse(const aap_protobuf::channel::control::ping::PingResponse& response)
|
||||||
{
|
{
|
||||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] Ping response, timestamp: " << response.timestamp();
|
OPENAUTO_LOG(info) << "[AndroidAutoEntity] Ping response, timestamp: " << response.timestamp();
|
||||||
pinger_->pong();
|
pinger_->pong();
|
||||||
@ -302,7 +390,7 @@ void AndroidAutoEntity::sendPing()
|
|||||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||||
promise->then([]() {}, std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
promise->then([]() {}, std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||||
|
|
||||||
aasdk::proto::messages::PingRequest request;
|
aap_protobuf::channel::control::ping::PingRequest request;
|
||||||
auto timestamp = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now().time_since_epoch());
|
auto timestamp = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now().time_since_epoch());
|
||||||
request.set_timestamp(timestamp.count());
|
request.set_timestamp(timestamp.count());
|
||||||
controlServiceChannel_->sendPingRequest(request, std::move(promise));
|
controlServiceChannel_->sendPingRequest(request, std::move(promise));
|
||||||
|
@ -16,14 +16,14 @@
|
|||||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <f1x/aasdk/USB/AOAPDevice.hpp>
|
#include <aasdk/USB/AOAPDevice.hpp>
|
||||||
#include <f1x/aasdk/Transport/SSLWrapper.hpp>
|
#include <aasdk/Transport/SSLWrapper.hpp>
|
||||||
#include <f1x/aasdk/Transport/USBTransport.hpp>
|
#include <aasdk/Transport/USBTransport.hpp>
|
||||||
#include <f1x/aasdk/Transport/TCPTransport.hpp>
|
#include <aasdk/Transport/TCPTransport.hpp>
|
||||||
#include <f1x/aasdk/Messenger/Cryptor.hpp>
|
#include <aasdk/Messenger/Cryptor.hpp>
|
||||||
#include <f1x/aasdk/Messenger/MessageInStream.hpp>
|
#include <aasdk/Messenger/MessageInStream.hpp>
|
||||||
#include <f1x/aasdk/Messenger/MessageOutStream.hpp>
|
#include <aasdk/Messenger/MessageOutStream.hpp>
|
||||||
#include <f1x/aasdk/Messenger/Messenger.hpp>
|
#include <aasdk/Messenger/Messenger.hpp>
|
||||||
#include <f1x/openauto/autoapp/Service/AndroidAutoEntityFactory.hpp>
|
#include <f1x/openauto/autoapp/Service/AndroidAutoEntityFactory.hpp>
|
||||||
#include <f1x/openauto/autoapp/Service/AndroidAutoEntity.hpp>
|
#include <f1x/openauto/autoapp/Service/AndroidAutoEntity.hpp>
|
||||||
#include <f1x/openauto/autoapp/Service/Pinger.hpp>
|
#include <f1x/openauto/autoapp/Service/Pinger.hpp>
|
||||||
|
@ -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());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
122
src/autoapp/Service/Bluetooth/BluetoothService.cpp
Normal file
122
src/autoapp/Service/Bluetooth/BluetoothService.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/Bluetooth/BluetoothService.hpp>
|
||||||
|
|
||||||
|
namespace f1x {
|
||||||
|
namespace openauto {
|
||||||
|
namespace autoapp {
|
||||||
|
namespace service {
|
||||||
|
namespace 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::channel::control::servicediscovery::notification::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_service();
|
||||||
|
bluetoothChannel->set_adapter_address(bluetoothDevice_->getLocalAddress());
|
||||||
|
bluetoothChannel->add_supported_pairing_methods(aap_protobuf::channel::bluetooth::event::BluetoothPairingMethod::BLUETOOTH_PAIRING_PIN);
|
||||||
|
bluetoothChannel->add_supported_pairing_methods(aap_protobuf::channel::bluetooth::event::BluetoothPairingMethod::BLUETOOTH_PAIRING_NUMERIC_COMPARISON);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BluetoothService::onChannelOpenRequest(const aap_protobuf::channel::ChannelOpenRequest &request) {
|
||||||
|
OPENAUTO_LOG(info) << "[BluetoothService] open request, priority: " << request.priority();
|
||||||
|
const aap_protobuf::shared::MessageStatus status = aap_protobuf::shared::MessageStatus::STATUS_SUCCESS;
|
||||||
|
OPENAUTO_LOG(info) << "[BluetoothService] open status: " << status;
|
||||||
|
|
||||||
|
aap_protobuf::channel::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 aap_protobuf::channel::bluetooth::event::BluetoothPairingRequest &request) {
|
||||||
|
OPENAUTO_LOG(info) << "[BluetoothService] pairing request, address: " << request.phone_address();
|
||||||
|
|
||||||
|
aap_protobuf::service::bluetooth::message::BluetoothPairingResponse response;
|
||||||
|
|
||||||
|
const auto isPaired = bluetoothDevice_->isPaired(request.phone_address());
|
||||||
|
response.set_already_paired(isPaired);
|
||||||
|
response.set_status(aap_protobuf::shared::MessageStatus::STATUS_SUCCESS);
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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,79 @@
|
|||||||
|
/*
|
||||||
|
* 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 {
|
||||||
|
namespace openauto {
|
||||||
|
namespace autoapp {
|
||||||
|
namespace service {
|
||||||
|
namespace 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::channel::control::servicediscovery::notification::ServiceDiscoveryResponse &response) {
|
||||||
|
OPENAUTO_LOG(info) << "[GenericNotificationService] fill features.";
|
||||||
|
|
||||||
|
auto *channelDescriptor = response.add_channels();
|
||||||
|
channelDescriptor->set_channel_id(static_cast<uint32_t>(channel_->getId()));
|
||||||
|
|
||||||
|
auto *vendorExtension = channelDescriptor->mutable_wifi_projection_service();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GenericNotificationService::onChannelError(const aasdk::error::Error &e) {
|
||||||
|
OPENAUTO_LOG(error) << "[GenericNotificationService] channel error: " << 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));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
196
src/autoapp/Service/InputSource/InputSourceService.cpp
Normal file
196
src/autoapp/Service/InputSource/InputSourceService.cpp
Normal file
@ -0,0 +1,196 @@
|
|||||||
|
/*
|
||||||
|
* 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 <aap_protobuf/service/input/message/InputEventIndication.pb.h>
|
||||||
|
#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) << "[InputService] start.";
|
||||||
|
channel_->receive(this->shared_from_this());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void InputSourceService::stop() {
|
||||||
|
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||||
|
OPENAUTO_LOG(info) << "[InputService] stop.";
|
||||||
|
inputDevice_->stop();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void InputSourceService::pause() {
|
||||||
|
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||||
|
OPENAUTO_LOG(info) << "[InputService] pause.";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void InputSourceService::resume() {
|
||||||
|
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||||
|
OPENAUTO_LOG(info) << "[InputService] resume.";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void InputSourceService::fillFeatures(
|
||||||
|
aap_protobuf::channel::control::servicediscovery::notification::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_service();
|
||||||
|
|
||||||
|
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->add_touch_screen_config();
|
||||||
|
|
||||||
|
touchscreenConfig->set_width(touchscreenSurface.width());
|
||||||
|
touchscreenConfig->set_height(touchscreenSurface.height());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void InputSourceService::onChannelOpenRequest(const aap_protobuf::channel::ChannelOpenRequest &request) {
|
||||||
|
OPENAUTO_LOG(info) << "[InputService] open request, priority: " << request.priority();
|
||||||
|
const aap_protobuf::shared::MessageStatus status = aap_protobuf::shared::MessageStatus::STATUS_SUCCESS;
|
||||||
|
OPENAUTO_LOG(info) << "[InputService] open status: " << status;
|
||||||
|
|
||||||
|
aap_protobuf::channel::ChannelOpenResponse response;
|
||||||
|
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::onBindingRequest(const aap_protobuf::channel::input::event::BindingRequest &request) {
|
||||||
|
OPENAUTO_LOG(info) << "[InputService] binding request, scan codes 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) << "[InputService] binding request, scan code: " << request.keycodes(i)
|
||||||
|
<< " is not supported.";
|
||||||
|
|
||||||
|
status = aap_protobuf::shared::MessageStatus::STATUS_UNSOLICITED_MESSAGE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
aap_protobuf::service::media::sink::message::BindingResponse response;
|
||||||
|
response.set_status(status);
|
||||||
|
|
||||||
|
if (status == aap_protobuf::shared::MessageStatus::STATUS_SUCCESS) {
|
||||||
|
inputDevice_->start(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
OPENAUTO_LOG(info) << "[InputService] binding request, status: " << status;
|
||||||
|
|
||||||
|
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||||
|
promise->then([]() {},
|
||||||
|
std::bind(&InputSourceService::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||||
|
channel_->sendBindingResponse(response, std::move(promise));
|
||||||
|
channel_->receive(this->shared_from_this());
|
||||||
|
}
|
||||||
|
|
||||||
|
void InputSourceService::onChannelError(const aasdk::error::Error &e) {
|
||||||
|
OPENAUTO_LOG(error) << "[InputSourceService] channel error: " << e.what();
|
||||||
|
}
|
||||||
|
|
||||||
|
void InputSourceService::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)]() {
|
||||||
|
aap_protobuf::service::input::message::InputEventIndication inputEventIndication;
|
||||||
|
inputEventIndication.set_timestamp(timestamp.count());
|
||||||
|
|
||||||
|
if (event.code == aap_protobuf::service::media::sink::KeyCode::KEYCODE_ROTARY_CONTROLLER) {
|
||||||
|
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_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_->sendInputEventIndication(inputEventIndication, std::move(promise));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void InputSourceService::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)]() {
|
||||||
|
aap_protobuf::service::input::message::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(&InputSourceService::onChannelError, this->shared_from_this(),
|
||||||
|
std::placeholders::_1));
|
||||||
|
channel_->sendInputEventIndication(inputEventIndication, std::move(promise));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
79
src/autoapp/Service/MediaBrowser/MediaBrowserService.cpp
Normal file
79
src/autoapp/Service/MediaBrowser/MediaBrowserService.cpp
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
/*
|
||||||
|
* 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::channel::control::servicediscovery::notification::ServiceDiscoveryResponse &response) {
|
||||||
|
OPENAUTO_LOG(info) << "[MediaBrowserService] fill features.";
|
||||||
|
|
||||||
|
auto *channelDescriptor = response.add_channels();
|
||||||
|
channelDescriptor->set_channel_id(static_cast<uint32_t>(channel_->getId()));
|
||||||
|
|
||||||
|
auto *vendorExtension = channelDescriptor->mutable_wifi_projection_service();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MediaBrowserService::onChannelError(const aasdk::error::Error &e) {
|
||||||
|
OPENAUTO_LOG(error) << "[MediaBrowserService] channel error: " << e.what();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,79 @@
|
|||||||
|
/*
|
||||||
|
* 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::channel::control::servicediscovery::notification::ServiceDiscoveryResponse &response) {
|
||||||
|
OPENAUTO_LOG(info) << "[MediaPlaybackStatusService] fill features.";
|
||||||
|
|
||||||
|
auto *channelDescriptor = response.add_channels();
|
||||||
|
channelDescriptor->set_channel_id(static_cast<uint32_t>(channel_->getId()));
|
||||||
|
|
||||||
|
auto *vendorExtension = channelDescriptor->mutable_wifi_projection_service();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MediaPlaybackStatusService::onChannelError(const aasdk::error::Error &e) {
|
||||||
|
OPENAUTO_LOG(error) << "[MediaPlaybackStatusService] channel error: " << e.what();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
217
src/autoapp/Service/MediaSink/AudioMediaSinkService.cpp
Normal file
217
src/autoapp/Service/MediaSink/AudioMediaSinkService.cpp
Normal file
@ -0,0 +1,217 @@
|
|||||||
|
/*
|
||||||
|
* 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) << "[MediaSinkService] start, 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) << "[MediaSinkService] stop, channel: "
|
||||||
|
<< aasdk::messenger::channelIdToString(channel_->getId());
|
||||||
|
audioOutput_->stop();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void AudioMediaSinkService::pause() {
|
||||||
|
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||||
|
OPENAUTO_LOG(info) << "[MediaSinkService] pause.";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void AudioMediaSinkService::resume() {
|
||||||
|
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||||
|
OPENAUTO_LOG(info) << "[MediaSinkService] resume.";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Service Discovery
|
||||||
|
*/
|
||||||
|
|
||||||
|
void AudioMediaSinkService::fillFeatures(
|
||||||
|
aap_protobuf::channel::control::servicediscovery::notification::ServiceDiscoveryResponse &response) {
|
||||||
|
OPENAUTO_LOG(info) << "[MediaSinkService] 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_media_sink_service();
|
||||||
|
|
||||||
|
audioChannel->set_stream_type(
|
||||||
|
aap_protobuf::service::media::shared::message::MediaCodecType::MEDIA_CODEC_AUDIO_PCM);
|
||||||
|
|
||||||
|
switch (channel_->getId()) {
|
||||||
|
case aasdk::messenger::ChannelId::MEDIA_SINK_SYSTEM_AUDIO:
|
||||||
|
audioChannel->set_audio_type(
|
||||||
|
aap_protobuf::service::media::sink::AudioStreamType::AUDIO_STREAM_SYSTEM_AUDIO);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case aasdk::messenger::ChannelId::MEDIA_SINK_MEDIA_AUDIO:
|
||||||
|
audioChannel->set_audio_type(aap_protobuf::service::media::sink::AudioStreamType::AUDIO_STREAM_MEDIA);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case aasdk::messenger::ChannelId::MEDIA_SINK_GUIDANCE_AUDIO:
|
||||||
|
audioChannel->set_audio_type(
|
||||||
|
aap_protobuf::service::media::sink::AudioStreamType::AUDIO_STREAM_GUIDANCE);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case aasdk::messenger::ChannelId::MEDIA_SINK_TELEPHONY_AUDIO:
|
||||||
|
audioChannel->set_audio_type(
|
||||||
|
aap_protobuf::service::media::sink::AudioStreamType::AUDIO_STREAM_TELEPHONY);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Base Channel Handling
|
||||||
|
*/
|
||||||
|
|
||||||
|
void AudioMediaSinkService::onChannelOpenRequest(const aap_protobuf::channel::ChannelOpenRequest &request) {
|
||||||
|
OPENAUTO_LOG(info) << "[MediaSinkService] Channel Open Request with priority " << request.priority()
|
||||||
|
<< " on channel " << aasdk::messenger::channelIdToString(channel_->getId());
|
||||||
|
|
||||||
|
OPENAUTO_LOG(debug) << "[AudioMediaSinkService] Sample Rate: " << audioOutput_->getSampleRate()
|
||||||
|
<< ", Sample Size: " << audioOutput_->getSampleSize()
|
||||||
|
<< ", Channels: " << audioOutput_->getChannelCount();
|
||||||
|
|
||||||
|
const aap_protobuf::shared::MessageStatus status = audioOutput_->open()
|
||||||
|
? aap_protobuf::shared::MessageStatus::STATUS_SUCCESS
|
||||||
|
: aap_protobuf::shared::MessageStatus::STATUS_INTERNAL_ERROR;
|
||||||
|
|
||||||
|
OPENAUTO_LOG(info) << "[MediaSinkService] open status: " << status;
|
||||||
|
|
||||||
|
aap_protobuf::channel::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) << "[MediaSinkService] channel error: " << e.what()
|
||||||
|
<< ", channel: " << aasdk::messenger::channelIdToString(channel_->getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Media Channel Handling
|
||||||
|
*/
|
||||||
|
|
||||||
|
void AudioMediaSinkService::onMediaChannelSetupRequest(const aap_protobuf::channel::media::event::Setup &request) {
|
||||||
|
|
||||||
|
OPENAUTO_LOG(info) << "[MediaSinkService] setup request"
|
||||||
|
<< ", channel: " << aasdk::messenger::channelIdToString(channel_->getId())
|
||||||
|
<< ", codec type: " << MediaCodecType_Name(request.type());
|
||||||
|
|
||||||
|
auto status = aap_protobuf::service::media::sink::MediaSinkChannelSetupStatus::STATUS_READY;
|
||||||
|
|
||||||
|
OPENAUTO_LOG(info) << "[MediaSinkService] setup status: " << status;
|
||||||
|
|
||||||
|
aap_protobuf::service::media::sink::message::MediaSinkChannelSetupResponse response;
|
||||||
|
response.set_media_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::channel::media::event::Start &indication) {
|
||||||
|
OPENAUTO_LOG(info) << "[MediaSinkService] start indication"
|
||||||
|
<< ", channel: " << 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::channel::media::event::Stop &indication) {
|
||||||
|
OPENAUTO_LOG(info) << "[MediaSinkService] stop indication"
|
||||||
|
<< ", channel: " << 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) {
|
||||||
|
audioOutput_->write(timestamp, buffer);
|
||||||
|
|
||||||
|
// TODO: Move MediaSourceMediaAckIndication to Ack and move to Shared.
|
||||||
|
aap_protobuf::service::media::source::message::MediaSourceMediaAckIndication 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) {
|
||||||
|
this->onMediaWithTimestampIndication(0, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
43
src/autoapp/Service/MediaSink/GuidanceAudioService.cpp
Normal file
43
src/autoapp/Service/MediaSink/GuidanceAudioService.cpp
Normal file
@ -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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <f1x/openauto/autoapp/Service/MediaSink/GuidanceAudioService.hpp>
|
||||||
|
|
||||||
|
namespace f1x {
|
||||||
|
namespace openauto {
|
||||||
|
namespace autoapp {
|
||||||
|
namespace service {
|
||||||
|
namespace 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)) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
42
src/autoapp/Service/MediaSink/MediaAudioService.cpp
Normal file
42
src/autoapp/Service/MediaSink/MediaAudioService.cpp
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* 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 {
|
||||||
|
namespace openauto {
|
||||||
|
namespace autoapp {
|
||||||
|
namespace service {
|
||||||
|
namespace 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)) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
42
src/autoapp/Service/MediaSink/SystemAudioService.cpp
Normal file
42
src/autoapp/Service/MediaSink/SystemAudioService.cpp
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* 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/MediaSinkService.hpp>
|
||||||
|
#include <aasdk/Channel/MediaSink/Audio/Channel/SystemAudioChannel.hpp>
|
||||||
|
#include <f1x/openauto/autoapp/Service/MediaSink/SystemAudioService.hpp>
|
||||||
|
|
||||||
|
namespace f1x {
|
||||||
|
namespace openauto {
|
||||||
|
namespace autoapp {
|
||||||
|
namespace service {
|
||||||
|
namespace 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)) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
41
src/autoapp/Service/MediaSink/TelephonyAudioService.cpp
Normal file
41
src/autoapp/Service/MediaSink/TelephonyAudioService.cpp
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* 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/MediaSinkService.hpp>
|
||||||
|
#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)) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
208
src/autoapp/Service/MediaSink/VideoMediaSinkService.cpp
Normal file
208
src/autoapp/Service/MediaSink/VideoMediaSinkService.cpp
Normal file
@ -0,0 +1,208 @@
|
|||||||
|
/*
|
||||||
|
* 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) << "[MediaSinkService] start, 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) << "[MediaSinkService] stop, channel: "
|
||||||
|
<< aasdk::messenger::channelIdToString(channel_->getId());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void VideoMediaSinkService::pause() {
|
||||||
|
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||||
|
OPENAUTO_LOG(info) << "[MediaSinkService] pause.";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void VideoMediaSinkService::resume() {
|
||||||
|
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||||
|
OPENAUTO_LOG(info) << "[MediaSinkService] resume.";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void VideoMediaSinkService::fillFeatures(
|
||||||
|
aap_protobuf::channel::control::servicediscovery::notification::ServiceDiscoveryResponse &response) {
|
||||||
|
OPENAUTO_LOG(info) << "[MediaSinkService] fill features, channel: "
|
||||||
|
<< aasdk::messenger::channelIdToString(channel_->getId());
|
||||||
|
|
||||||
|
auto *channelDescriptor = response.add_channels();
|
||||||
|
channelDescriptor->set_channel_id(static_cast<uint32_t>(channel_->getId()));
|
||||||
|
|
||||||
|
auto *videoChannel = channelDescriptor->mutable_media_sink_service();
|
||||||
|
videoChannel->set_stream_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());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void VideoMediaSinkService::onMediaChannelSetupRequest(const aap_protobuf::channel::media::event::Setup &request) {
|
||||||
|
|
||||||
|
OPENAUTO_LOG(info) << "[MediaSinkService] setup request"
|
||||||
|
<< ", channel: " << aasdk::messenger::channelIdToString(channel_->getId())
|
||||||
|
<< ", codec type: " << MediaCodecType_Name(request.type());
|
||||||
|
|
||||||
|
auto status = videoOutput_->init() ? aap_protobuf::service::media::sink::MediaSinkChannelSetupStatus::STATUS_READY
|
||||||
|
: aap_protobuf::service::media::sink::MediaSinkChannelSetupStatus::STATUS_WAIT;
|
||||||
|
|
||||||
|
OPENAUTO_LOG(info) << "[MediaSinkService] setup status: " << status;
|
||||||
|
|
||||||
|
aap_protobuf::service::media::sink::message::MediaSinkChannelSetupResponse response;
|
||||||
|
response.set_media_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::channel::ChannelOpenRequest &request) {
|
||||||
|
OPENAUTO_LOG(info) << "[MediaSinkService] Channel Open Request with priority " << request.priority()
|
||||||
|
<< " on channel " << aasdk::messenger::channelIdToString(channel_->getId());
|
||||||
|
|
||||||
|
const aap_protobuf::shared::MessageStatus status = videoOutput_->open()
|
||||||
|
? aap_protobuf::shared::MessageStatus::STATUS_SUCCESS
|
||||||
|
: aap_protobuf::shared::MessageStatus::STATUS_INTERNAL_ERROR;
|
||||||
|
|
||||||
|
OPENAUTO_LOG(info) << "[MediaSinkService] open status: " << status;
|
||||||
|
|
||||||
|
aap_protobuf::channel::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::channel::media::event::Start &indication) {
|
||||||
|
OPENAUTO_LOG(info) << "[MediaSinkService] start indication"
|
||||||
|
<< ", channel: " << 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::channel::media::event::Stop &indication) {
|
||||||
|
OPENAUTO_LOG(info) << "[MediaSinkService] stop indication"
|
||||||
|
<< ", channel: " << 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) {
|
||||||
|
videoOutput_->write(timestamp, buffer);
|
||||||
|
|
||||||
|
aap_protobuf::service::media::source::message::MediaSourceMediaAckIndication 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) {
|
||||||
|
this->onMediaWithTimestampIndication(0, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VideoMediaSinkService::onChannelError(const aasdk::error::Error &e) {
|
||||||
|
OPENAUTO_LOG(error) << "[MediaSinkService] channel error: " << e.what()
|
||||||
|
<< ", channel: " << aasdk::messenger::channelIdToString(channel_->getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void VideoMediaSinkService::onVideoFocusRequest(
|
||||||
|
const aap_protobuf::channel::control::focus::video::event::VideoFocusRequestNotification &request) {
|
||||||
|
OPENAUTO_LOG(info) << "[VideoMediaSinkService] video focus request, display index: " << request.disp_channel_id()
|
||||||
|
<< ", focus mode: " << VideoFocusMode_Name(request.mode())
|
||||||
|
<< ", focus reason: " << VideoFocusReason_Name(request.reason());
|
||||||
|
// package aap_protobuf.channel.control.focus.video.shared;
|
||||||
|
// stop video service on go back to openauto
|
||||||
|
if (request.mode() == aap_protobuf::channel::control::focus::video::shared::VideoFocusMode::VIDEO_FOCUS_NATIVE) {
|
||||||
|
OPENAUTO_LOG(info) << "[VideoMediaSinkService] Back to CSNG...";
|
||||||
|
try {
|
||||||
|
if (!std::ifstream("/tmp/entityexit")) {
|
||||||
|
std::ofstream("/tmp/entityexit");
|
||||||
|
}
|
||||||
|
} catch (...) {
|
||||||
|
OPENAUTO_LOG(error) << "[VideoMediaSinkService] Error in creating entityexit";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this->sendVideoFocusIndication();
|
||||||
|
channel_->receive(this->shared_from_this());
|
||||||
|
}
|
||||||
|
|
||||||
|
void VideoMediaSinkService::sendVideoFocusIndication() {
|
||||||
|
OPENAUTO_LOG(info) << "[VideoMediaSinkService] video focus indication.";
|
||||||
|
|
||||||
|
aap_protobuf::channel::control::focus::video::notification::VideoFocusNotification videoFocusIndication;
|
||||||
|
videoFocusIndication.set_focus(aap_protobuf::channel::control::focus::video::shared::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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
41
src/autoapp/Service/MediaSink/VideoService.cpp
Normal file
41
src/autoapp/Service/MediaSink/VideoService.cpp
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* 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/MediaSinkService.hpp>
|
||||||
|
#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)) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
272
src/autoapp/Service/MediaSource/MediaSourceService.cpp
Normal file
272
src/autoapp/Service/MediaSource/MediaSourceService.cpp
Normal file
@ -0,0 +1,272 @@
|
|||||||
|
/*
|
||||||
|
* 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/MediaSource/MediaSourceService.hpp>
|
||||||
|
#include <aap_protobuf/service/media/sink/message/MediaSinkChannelSetupResponse.pb.h>
|
||||||
|
|
||||||
|
namespace f1x {
|
||||||
|
namespace openauto {
|
||||||
|
namespace autoapp {
|
||||||
|
namespace service {
|
||||||
|
namespace 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) << "[AudioInputService] start.";
|
||||||
|
channel_->receive(this->shared_from_this());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void MediaSourceService::stop() {
|
||||||
|
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||||
|
OPENAUTO_LOG(info) << "[AudioInputService] stop.";
|
||||||
|
audioInput_->stop();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void MediaSourceService::pause() {
|
||||||
|
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||||
|
OPENAUTO_LOG(info) << "[AudioInputService] pause.";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void MediaSourceService::resume() {
|
||||||
|
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||||
|
OPENAUTO_LOG(info) << "[AudioInputService] resume.";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Service Discovery
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fill Features of Service
|
||||||
|
* @param response
|
||||||
|
*/
|
||||||
|
void MediaSourceService::fillFeatures(
|
||||||
|
aap_protobuf::channel::control::servicediscovery::notification::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_media_source_service();
|
||||||
|
avInputChannel->set_stream_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::channel::ChannelOpenRequest &request) {
|
||||||
|
OPENAUTO_LOG(info) << "[AudioInputService] open request, priority: " << request.priority();
|
||||||
|
const aap_protobuf::shared::MessageStatus status = audioInput_->open()
|
||||||
|
? aap_protobuf::shared::MessageStatus::STATUS_SUCCESS
|
||||||
|
: aap_protobuf::shared::MessageStatus::STATUS_UNSOLICITED_MESSAGE;
|
||||||
|
OPENAUTO_LOG(info) << "[AudioInputService] open status: " << status;
|
||||||
|
|
||||||
|
aap_protobuf::channel::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) << "[AudioInputService] channel error: " << e.what();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Media Channel Handling
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic Media Channel Setup Request
|
||||||
|
* @param request
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
MediaSourceService::onMediaChannelSetupRequest(const aap_protobuf::channel::media::event::Setup &request) {
|
||||||
|
|
||||||
|
OPENAUTO_LOG(info) << "[MediaSinkService] setup request"
|
||||||
|
<< ", channel: " << aasdk::messenger::channelIdToString(channel_->getId())
|
||||||
|
<< ", codec type: " << MediaCodecType_Name(request.type());
|
||||||
|
|
||||||
|
auto status = aap_protobuf::service::media::sink::MediaSinkChannelSetupStatus::STATUS_READY;
|
||||||
|
|
||||||
|
OPENAUTO_LOG(info) << "[MediaSinkService] setup status: " << status;
|
||||||
|
|
||||||
|
aap_protobuf::service::media::sink::message::MediaSinkChannelSetupResponse response;
|
||||||
|
response.set_media_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::MediaSourceMediaAckIndication &) {
|
||||||
|
channel_->receive(this->shared_from_this());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Source Media Channel Handling
|
||||||
|
*/
|
||||||
|
|
||||||
|
// TODO: These are Source Channel Handlers - should be moved to their own handlers in case any more are implemented in the future.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle request to open Microphone Channel
|
||||||
|
* @param request
|
||||||
|
*/
|
||||||
|
void MediaSourceService::onMediaSourceOpenRequest(
|
||||||
|
const aap_protobuf::service::media::source::message::MicrophoneRequest &request) {
|
||||||
|
OPENAUTO_LOG(info) << "[AudioInputService] input open request, open: " << request.open()
|
||||||
|
<< ", anc: " << request.anc_enabled()
|
||||||
|
<< ", ec: " << request.ec_enabled()
|
||||||
|
<< ", max unacked: " << request.max_unacked();
|
||||||
|
|
||||||
|
if (request.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) << "[AudioInputService] audio input open failed.";
|
||||||
|
|
||||||
|
aap_protobuf::service::media::source::message::MicrophoneResponse response;
|
||||||
|
response.set_session_id(session_);
|
||||||
|
// TODO: Matches previous number, but doesn't seem like the right status.
|
||||||
|
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 {
|
||||||
|
audioInput_->stop();
|
||||||
|
|
||||||
|
aap_protobuf::service::media::source::message::MicrophoneResponse response;
|
||||||
|
response.set_session_id(session_);
|
||||||
|
// TODO: Matches previous number, but doesn't seem like the right status.
|
||||||
|
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(info) << "[AudioInputService] audio input open succeed.";
|
||||||
|
|
||||||
|
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) {
|
||||||
|
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() {
|
||||||
|
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(info) << "[AudioInputService] audio input read rejected.";
|
||||||
|
});
|
||||||
|
|
||||||
|
audioInput_->read(std::move(readPromise));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,79 @@
|
|||||||
|
/*
|
||||||
|
* 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 {
|
||||||
|
namespace openauto {
|
||||||
|
namespace autoapp {
|
||||||
|
namespace service {
|
||||||
|
namespace 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::channel::control::servicediscovery::notification::ServiceDiscoveryResponse &response) {
|
||||||
|
OPENAUTO_LOG(info) << "[NavigationStatusService] fill features.";
|
||||||
|
|
||||||
|
auto *channelDescriptor = response.add_channels();
|
||||||
|
channelDescriptor->set_channel_id(static_cast<uint32_t>(channel_->getId()));
|
||||||
|
|
||||||
|
auto *vendorExtension = channelDescriptor->mutable_wifi_projection_service();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NavigationStatusService::onChannelError(const aasdk::error::Error &e) {
|
||||||
|
OPENAUTO_LOG(error) << "[NavigationStatusService] channel error: " << e.what();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
81
src/autoapp/Service/PhoneStatus/PhoneStatusService.cpp
Normal file
81
src/autoapp/Service/PhoneStatus/PhoneStatusService.cpp
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
/*
|
||||||
|
* 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::channel::control::servicediscovery::notification::ServiceDiscoveryResponse &response) {
|
||||||
|
OPENAUTO_LOG(info) << "[PhoneStatusService] fill features.";
|
||||||
|
|
||||||
|
auto *channelDescriptor = response.add_channels();
|
||||||
|
channelDescriptor->set_channel_id(static_cast<uint32_t>(channel_->getId()));
|
||||||
|
|
||||||
|
auto *vendorExtension = channelDescriptor->mutable_wifi_projection_service();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PhoneStatusService::onChannelError(const aasdk::error::Error &e) {
|
||||||
|
OPENAUTO_LOG(error) << "[PhoneStatusService] channel error: " << e.what();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
81
src/autoapp/Service/Radio/RadioService.cpp
Normal file
81
src/autoapp/Service/Radio/RadioService.cpp
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
/*
|
||||||
|
* 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 {
|
||||||
|
namespace openauto {
|
||||||
|
namespace autoapp {
|
||||||
|
namespace service {
|
||||||
|
namespace 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(info) << "[RadioService] start.";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void RadioService::stop() {
|
||||||
|
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||||
|
OPENAUTO_LOG(info) << "[RadioService] stop.";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void RadioService::pause() {
|
||||||
|
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||||
|
OPENAUTO_LOG(info) << "[RadioService] pause.";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void RadioService::resume() {
|
||||||
|
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||||
|
OPENAUTO_LOG(info) << "[RadioService] resume.";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void RadioService::fillFeatures(
|
||||||
|
aap_protobuf::channel::control::servicediscovery::notification::ServiceDiscoveryResponse &response) {
|
||||||
|
OPENAUTO_LOG(info) << "[RadioService] fill features.";
|
||||||
|
|
||||||
|
auto *channelDescriptor = response.add_channels();
|
||||||
|
channelDescriptor->set_channel_id(static_cast<uint32_t>(channel_->getId()));
|
||||||
|
|
||||||
|
auto *vendorExtension = channelDescriptor->mutable_wifi_projection_service();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RadioService::onChannelError(const aasdk::error::Error &e) {
|
||||||
|
OPENAUTO_LOG(error) << "[RadioService] channel error: " << e.what();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
246
src/autoapp/Service/Sensor/SensorService.cpp
Normal file
246
src/autoapp/Service/Sensor/SensorService.cpp
Normal file
@ -0,0 +1,246 @@
|
|||||||
|
/*
|
||||||
|
* 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 <aap_protobuf/service/sensor/message/DrivingStatus.pb.h>
|
||||||
|
#include <aap_protobuf/service/sensor/message/SensorType.pb.h>
|
||||||
|
#include <f1x/openauto/Common/Log.hpp>
|
||||||
|
#include <f1x/openauto/autoapp/Service/Sensor/SensorService.hpp>
|
||||||
|
#include <fstream>
|
||||||
|
#include <cmath>
|
||||||
|
#include <gps.h>
|
||||||
|
|
||||||
|
namespace f1x {
|
||||||
|
namespace openauto {
|
||||||
|
namespace autoapp {
|
||||||
|
namespace service {
|
||||||
|
namespace sensor {
|
||||||
|
SensorService::SensorService(boost::asio::io_service &ioService,
|
||||||
|
aasdk::messenger::IMessenger::Pointer messenger)
|
||||||
|
: strand_(ioService),
|
||||||
|
timer_(ioService),
|
||||||
|
channel_(std::make_shared<aasdk::channel::sensor::SensorService>(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::channel::control::servicediscovery::notification::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_service();
|
||||||
|
sensorChannel->add_sensors()->set_sensor_type(aap_protobuf::service::sensor::message::SensorType::SENSOR_DRIVING_STATUS_DATA);
|
||||||
|
sensorChannel->add_sensors()->set_sensor_type(aap_protobuf::service::sensor::message::SensorType::SENSOR_LOCATION);
|
||||||
|
sensorChannel->add_sensors()->set_sensor_type(aap_protobuf::service::sensor::message::SensorType::SENSOR_NIGHT_MODE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SensorService::onChannelOpenRequest(const aap_protobuf::channel::ChannelOpenRequest &request) {
|
||||||
|
OPENAUTO_LOG(info) << "[SensorService] open request, priority: " << request.priority();
|
||||||
|
const aap_protobuf::shared::MessageStatus status = aap_protobuf::shared::MessageStatus::STATUS_SUCCESS;
|
||||||
|
OPENAUTO_LOG(info) << "[SensorService] open status: " << status;
|
||||||
|
|
||||||
|
aap_protobuf::channel::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 aap_protobuf::channel::sensor::event::SensorRequest &request) {
|
||||||
|
OPENAUTO_LOG(info) << "[SensorService] sensor start request, type: " << request.sensor_type();
|
||||||
|
|
||||||
|
aap_protobuf::service::sensor::message::SensorStartResponseMessage response;
|
||||||
|
response.set_status(aap_protobuf::shared::MessageStatus::STATUS_SUCCESS);
|
||||||
|
|
||||||
|
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||||
|
|
||||||
|
if (request.sensor_type() == aap_protobuf::service::sensor::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.sensor_type() == aap_protobuf::service::sensor::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() {
|
||||||
|
aap_protobuf::service::sensor::message::SensorBatch indication;
|
||||||
|
indication.add_driving_status_data()->set_status(aap_protobuf::service::sensor::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() {
|
||||||
|
aap_protobuf::service::sensor::message::SensorBatch indication;
|
||||||
|
|
||||||
|
if (SensorService::isNight) {
|
||||||
|
OPENAUTO_LOG(info) << "[SensorService] Mode night triggered";
|
||||||
|
indication.add_night_mode_data()->set_night_mode(true);
|
||||||
|
} else {
|
||||||
|
OPENAUTO_LOG(info) << "[SensorService] Mode day 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() {
|
||||||
|
aap_protobuf::service::sensor::message::SensorBatch indication;
|
||||||
|
auto *locInd = indication.add_location_data();
|
||||||
|
|
||||||
|
// epoch seconds
|
||||||
|
// locInd->set_timestamp(this->gpsData_.fix.time * 1e3);
|
||||||
|
// 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((this->gpsEnabled_) &&
|
||||||
|
(gps_waiting(&this->gpsData_, 0)) &&
|
||||||
|
//extern int gps_read(struct gps_data_t *, char *message, int message_len);
|
||||||
|
//(gps_read(&this->gpsData_) > 0) &&
|
||||||
|
(this->gpsData_.fix.status != MODE_NO_FIX) &&
|
||||||
|
(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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,261 +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
|
|
||||||
locInd->set_timestamp(this->gpsData_.fix.time * 1e3);
|
|
||||||
// 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();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((this->gpsEnabled_) &&
|
|
||||||
(gps_waiting(&this->gpsData_, 0)) &&
|
|
||||||
(gps_read(&this->gpsData_) > 0) &&
|
|
||||||
(this->gpsData_.status != STATUS_NO_FIX) &&
|
|
||||||
(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,27 @@
|
|||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
#include <f1x/aasdk/Channel/AV/MediaAudioServiceChannel.hpp>
|
|
||||||
#include <f1x/aasdk/Channel/AV/SystemAudioServiceChannel.hpp>
|
#include <aasdk/Channel/MediaSink/Audio/Channel/MediaAudioChannel.hpp>
|
||||||
#include <f1x/aasdk/Channel/AV/SpeechAudioServiceChannel.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/ServiceFactory.hpp>
|
||||||
#include <f1x/openauto/autoapp/Service/VideoService.hpp>
|
|
||||||
#include <f1x/openauto/autoapp/Service/MediaAudioService.hpp>
|
#include <f1x/openauto/autoapp/Service/MediaSink/VideoService.hpp>
|
||||||
#include <f1x/openauto/autoapp/Service/SpeechAudioService.hpp>
|
#include <f1x/openauto/autoapp/Service/MediaSink/MediaAudioService.hpp>
|
||||||
#include <f1x/openauto/autoapp/Service/SystemAudioService.hpp>
|
#include <f1x/openauto/autoapp/Service/MediaSink/GuidanceAudioService.hpp>
|
||||||
#include <f1x/openauto/autoapp/Service/AudioInputService.hpp>
|
#include <f1x/openauto/autoapp/Service/MediaSink/SystemAudioService.hpp>
|
||||||
#include <f1x/openauto/autoapp/Service/SensorService.hpp>
|
#include <f1x/openauto/autoapp/Service/MediaSink/TelephonyAudioService.hpp>
|
||||||
#include <f1x/openauto/autoapp/Service/BluetoothService.hpp>
|
|
||||||
#include <f1x/openauto/autoapp/Service/InputService.hpp>
|
#include <f1x/openauto/autoapp/Service/MediaSource/MediaSourceService.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/QtVideoOutput.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/OMXVideoOutput.hpp>
|
#include <f1x/openauto/autoapp/Projection/OMXVideoOutput.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/RtAudioOutput.hpp>
|
#include <f1x/openauto/autoapp/Projection/RtAudioOutput.hpp>
|
||||||
@ -39,124 +48,159 @@
|
|||||||
#include <f1x/openauto/autoapp/Projection/LocalBluetoothDevice.hpp>
|
#include <f1x/openauto/autoapp/Projection/LocalBluetoothDevice.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/RemoteBluetoothDevice.hpp>
|
#include <f1x/openauto/autoapp/Projection/RemoteBluetoothDevice.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/DummyBluetoothDevice.hpp>
|
#include <f1x/openauto/autoapp/Projection/DummyBluetoothDevice.hpp>
|
||||||
#include <f1x/openauto/autoapp/Service/WifiService.hpp>
|
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
|
||||||
{
|
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace service
|
|
||||||
{
|
|
||||||
|
|
||||||
ServiceFactory::ServiceFactory(boost::asio::io_service& ioService, configuration::IConfiguration::Pointer configuration)
|
namespace f1x {
|
||||||
: ioService_(ioService)
|
namespace openauto {
|
||||||
, configuration_(std::move(configuration))
|
namespace autoapp {
|
||||||
{
|
namespace service {
|
||||||
|
|
||||||
}
|
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 serviceList;
|
|
||||||
|
|
||||||
projection::IAudioInput::Pointer audioInput(new projection::QtAudioInput(1, 16, 16000), std::bind(&QObject::deleteLater, std::placeholders::_1));
|
// TODO: MEDIA SERVICE
|
||||||
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));
|
|
||||||
serviceList.emplace_back(this->createBluetoothService(messenger));
|
|
||||||
serviceList.emplace_back(this->createInputService(messenger));
|
|
||||||
serviceList.emplace_back(std::make_shared<WifiService>(configuration_));
|
|
||||||
|
|
||||||
return serviceList;
|
ServiceList ServiceFactory::create(aasdk::messenger::IMessenger::Pointer messenger) {
|
||||||
}
|
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<MediaSourceService>(ioService_, messenger, std::move(audioInput)));
|
||||||
|
*/
|
||||||
|
|
||||||
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)
|
this->createMediaSinkServices(serviceList, messenger);
|
||||||
{
|
this->createMediaSourceServices(serviceList, messenger);
|
||||||
projection::IBluetoothDevice::Pointer bluetoothDevice;
|
serviceList.emplace_back(this->createSensorService(messenger));
|
||||||
switch(configuration_->getBluetoothAdapterType())
|
serviceList.emplace_back(this->createBluetoothService(messenger));
|
||||||
{
|
serviceList.emplace_back(this->createInputService(messenger));
|
||||||
case configuration::BluetoothAdapterType::LOCAL:
|
serviceList.emplace_back(this->createWifiProjectionService(messenger));
|
||||||
bluetoothDevice = projection::IBluetoothDevice::Pointer(new projection::LocalBluetoothDevice(), std::bind(&QObject::deleteLater, std::placeholders::_1));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case configuration::BluetoothAdapterType::REMOTE:
|
return serviceList;
|
||||||
bluetoothDevice = std::make_shared<projection::RemoteBluetoothDevice>(configuration_->getBluetoothRemoteAdapterAddress());
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
IService::Pointer ServiceFactory::createBluetoothService(aasdk::messenger::IMessenger::Pointer messenger) {
|
||||||
bluetoothDevice = std::make_shared<projection::DummyBluetoothDevice>();
|
projection::IBluetoothDevice::Pointer bluetoothDevice;
|
||||||
break;
|
switch (configuration_->getBluetoothAdapterType()) {
|
||||||
}
|
case configuration::BluetoothAdapterType::LOCAL:
|
||||||
|
bluetoothDevice = projection::IBluetoothDevice::Pointer(new projection::LocalBluetoothDevice(),
|
||||||
|
std::bind(&QObject::deleteLater,
|
||||||
|
std::placeholders::_1));
|
||||||
|
break;
|
||||||
|
|
||||||
return std::make_shared<BluetoothService>(ioService_, messenger, std::move(bluetoothDevice));
|
case configuration::BluetoothAdapterType::REMOTE:
|
||||||
}
|
bluetoothDevice = std::make_shared<projection::RemoteBluetoothDevice>(
|
||||||
|
configuration_->getBluetoothRemoteAdapterAddress());
|
||||||
|
break;
|
||||||
|
|
||||||
IService::Pointer ServiceFactory::createInputService(aasdk::messenger::IMessenger::Pointer messenger)
|
default:
|
||||||
{
|
bluetoothDevice = std::make_shared<projection::DummyBluetoothDevice>();
|
||||||
QRect videoGeometry;
|
break;
|
||||||
switch(configuration_->getVideoResolution())
|
}
|
||||||
{
|
|
||||||
case aasdk::proto::enums::VideoResolution::_720p:
|
|
||||||
videoGeometry = QRect(0, 0, 1280, 720);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case aasdk::proto::enums::VideoResolution::_1080p:
|
return std::make_shared<bluetooth::BluetoothService>(ioService_, messenger, std::move(bluetoothDevice));
|
||||||
videoGeometry = QRect(0, 0, 1920, 1080);
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
IService::Pointer ServiceFactory::createInputService(aasdk::messenger::IMessenger::Pointer messenger) {
|
||||||
videoGeometry = QRect(0, 0, 800, 480);
|
QRect videoGeometry;
|
||||||
break;
|
switch (configuration_->getVideoResolution()) {
|
||||||
}
|
case aap_protobuf::service::media::shared::message::VideoCodecResolutionType::VIDEO_1280x720:
|
||||||
|
videoGeometry = QRect(0, 0, 1280, 720);
|
||||||
|
break;
|
||||||
|
|
||||||
QScreen* screen = QGuiApplication::primaryScreen();
|
case aap_protobuf::service::media::shared::message::VideoCodecResolutionType::VIDEO_1920x1080:
|
||||||
QRect screenGeometry = screen == nullptr ? QRect(0, 0, 1, 1) : screen->geometry();
|
videoGeometry = QRect(0, 0, 1920, 1080);
|
||||||
projection::IInputDevice::Pointer inputDevice(std::make_shared<projection::InputDevice>(*QApplication::instance(), configuration_, std::move(screenGeometry), std::move(videoGeometry)));
|
break;
|
||||||
|
|
||||||
return std::make_shared<InputService>(ioService_, messenger, std::move(inputDevice));
|
default:
|
||||||
}
|
videoGeometry = QRect(0, 0, 800, 480);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
void ServiceFactory::createAudioServices(ServiceList& serviceList, aasdk::messenger::IMessenger::Pointer messenger)
|
QScreen *screen = QGuiApplication::primaryScreen();
|
||||||
{
|
QRect screenGeometry = screen == nullptr ? QRect(0, 0, 1, 1) : screen->geometry();
|
||||||
if(configuration_->musicAudioChannelEnabled())
|
projection::IInputDevice::Pointer inputDevice(
|
||||||
{
|
std::make_shared<projection::InputDevice>(*QApplication::instance(), configuration_,
|
||||||
auto mediaAudioOutput = configuration_->getAudioOutputBackendType() == configuration::AudioOutputBackendType::RTAUDIO ?
|
std::move(screenGeometry), std::move(videoGeometry)));
|
||||||
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)));
|
return std::make_shared<inputsource::InputSourceService>(ioService_, messenger, std::move(inputDevice));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(configuration_->speechAudioChannelEnabled())
|
void ServiceFactory::createMediaSinkServices(ServiceList &serviceList,
|
||||||
{
|
aasdk::messenger::IMessenger::Pointer messenger) {
|
||||||
auto speechAudioOutput = configuration_->getAudioOutputBackendType() == configuration::AudioOutputBackendType::RTAUDIO ?
|
if (configuration_->musicAudioChannelEnabled()) {
|
||||||
std::make_shared<projection::RtAudioOutput>(1, 16, 16000) :
|
auto mediaAudioOutput =
|
||||||
projection::IAudioOutput::Pointer(new projection::QtAudioOutput(1, 16, 16000), std::bind(&QObject::deleteLater, std::placeholders::_1));
|
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<SpeechAudioService>(ioService_, messenger, std::move(speechAudioOutput)));
|
serviceList.emplace_back(
|
||||||
}
|
std::make_shared<mediasink::MediaAudioService>(ioService_, messenger, std::move(mediaAudioOutput)));
|
||||||
|
}
|
||||||
|
|
||||||
auto systemAudioOutput = configuration_->getAudioOutputBackendType() == configuration::AudioOutputBackendType::RTAUDIO ?
|
if (configuration_->guidanceAudioChannelEnabled()) {
|
||||||
|
auto guidanceAudioOutput =
|
||||||
|
configuration_->getAudioOutputBackendType() == configuration::AudioOutputBackendType::RTAUDIO ?
|
||||||
std::make_shared<projection::RtAudioOutput>(1, 16, 16000) :
|
std::make_shared<projection::RtAudioOutput>(1, 16, 16000) :
|
||||||
projection::IAudioOutput::Pointer(new projection::QtAudioOutput(1, 16, 16000), std::bind(&QObject::deleteLater, std::placeholders::_1));
|
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::GuidanceAudioService>(ioService_, messenger, std::move(guidanceAudioOutput)));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
if (configuration_->telephonyAudioChannelEnabled()) {
|
||||||
}
|
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<mediasink::TelephonyAudioService>(ioService_, messenger, std::move(telephonyAudioOutput)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* No Need to Check for systemAudioChannelEnabled - MUST be enabled by default.
|
||||||
|
*/
|
||||||
|
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
|
||||||
|
|
||||||
|
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) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
IService::Pointer ServiceFactory::createSensorService(aasdk::messenger::IMessenger::Pointer messenger) {
|
||||||
|
return std::make_shared<sensor::SensorService>(ioService_, messenger);
|
||||||
|
}
|
||||||
|
|
||||||
|
IService::Pointer ServiceFactory::createWifiProjectionService(aasdk::messenger::IMessenger::Pointer messenger) {
|
||||||
|
return std::make_shared<wifiprojection::WifiProjectionService>(ioService_, messenger);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 <f1x/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 <f1x/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,81 @@
|
|||||||
|
/*
|
||||||
|
* 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 {
|
||||||
|
namespace openauto {
|
||||||
|
namespace autoapp {
|
||||||
|
namespace service {
|
||||||
|
namespace 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::channel::control::servicediscovery::notification::ServiceDiscoveryResponse &response) {
|
||||||
|
OPENAUTO_LOG(info) << "[VendorExtensionService] fill features.";
|
||||||
|
|
||||||
|
auto *channelDescriptor = response.add_channels();
|
||||||
|
channelDescriptor->set_channel_id(static_cast<uint32_t>(channel_->getId()));
|
||||||
|
|
||||||
|
auto *vendorExtension = channelDescriptor->mutable_wifi_projection_service();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VendorExtensionService::onChannelError(const aasdk::error::Error &e) {
|
||||||
|
OPENAUTO_LOG(error) << "[VendorExtensionService] channel error: " << e.what();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
103
src/autoapp/Service/WifiProjection/WifiProjectionStatus.cpp
Normal file
103
src/autoapp/Service/WifiProjection/WifiProjectionStatus.cpp
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
/*
|
||||||
|
* 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>
|
||||||
|
|
||||||
|
namespace f1x {
|
||||||
|
namespace openauto {
|
||||||
|
namespace autoapp {
|
||||||
|
namespace service {
|
||||||
|
namespace wifiprojection {
|
||||||
|
WifiProjectionService::WifiProjectionService(boost::asio::io_service &ioService,
|
||||||
|
aasdk::messenger::IMessenger::Pointer messenger)
|
||||||
|
: 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::channel::control::servicediscovery::notification::ServiceDiscoveryResponse &response) {
|
||||||
|
OPENAUTO_LOG(info) << "[WifiProjectionService] fill features.";
|
||||||
|
|
||||||
|
auto *channelDescriptor = response.add_channels();
|
||||||
|
channelDescriptor->set_channel_id(static_cast<uint32_t>(channel_->getId()));
|
||||||
|
|
||||||
|
auto *wifiChannel = channelDescriptor->mutable_wifi_projection_service();
|
||||||
|
wifiChannel->set_car_wifi_bssid(""); // TODO: Temporarily disabled and populating with empty string.
|
||||||
|
}
|
||||||
|
|
||||||
|
void WifiProjectionService::onWifiCredentialsRequest(
|
||||||
|
const aap_protobuf::service::wifiprojection::message::WifiCredentialsRequest &request) {
|
||||||
|
// channel_->sendWifiCredentialsResponse(response, std::move(promise));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void WifiProjectionService::onChannelOpenRequest(const aap_protobuf::channel::ChannelOpenRequest &request) {
|
||||||
|
OPENAUTO_LOG(info) << "[WifiProjectionService] open request, priority: " << request.priority();
|
||||||
|
const aap_protobuf::shared::MessageStatus status = aap_protobuf::shared::MessageStatus::STATUS_SUCCESS;
|
||||||
|
OPENAUTO_LOG(info) << "[WifiProjectionService] open status: " << status;
|
||||||
|
|
||||||
|
aap_protobuf::channel::ChannelOpenResponse response;
|
||||||
|
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] channel error: " << e.what();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,69 +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/WifiService.hpp>
|
|
||||||
#include <fstream>
|
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
namespace f1x
|
|
||||||
{
|
|
||||||
namespace openauto
|
|
||||||
{
|
|
||||||
namespace autoapp
|
|
||||||
{
|
|
||||||
namespace service
|
|
||||||
{
|
|
||||||
|
|
||||||
WifiService::WifiService(configuration::IConfiguration::Pointer configuration)
|
|
||||||
: configuration_(std::move(configuration))
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void WifiService::start()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void WifiService::stop()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void WifiService::pause()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void WifiService::resume()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void WifiService::fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response)
|
|
||||||
{
|
|
||||||
OPENAUTO_LOG(info) << "[WifiService] fill features.";
|
|
||||||
|
|
||||||
auto* channelDescriptor = response.add_channels();
|
|
||||||
channelDescriptor->set_channel_id(14);
|
|
||||||
|
|
||||||
auto* channel = channelDescriptor->mutable_wifi_channel();
|
|
||||||
channel->set_ssid(configuration_->getParamFromFile("/etc/hostapd/hostapd.conf","ssid").toStdString());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -211,19 +211,19 @@ void SettingsWindow::onSave()
|
|||||||
configuration_->instantPlay(ui_->checkBoxInstantPlay->isChecked());
|
configuration_->instantPlay(ui_->checkBoxInstantPlay->isChecked());
|
||||||
configuration_->hideWarning(ui_->checkBoxDontShowAgain->isChecked());
|
configuration_->hideWarning(ui_->checkBoxDontShowAgain->isChecked());
|
||||||
|
|
||||||
configuration_->setVideoFPS(ui_->radioButton30FPS->isChecked() ? aasdk::proto::enums::VideoFPS::_30 : aasdk::proto::enums::VideoFPS::_60);
|
configuration_->setVideoFPS(ui_->radioButton30FPS->isChecked() ? aap_protobuf::service::media::shared::message::VideoFrameRateType::_30 : aap_protobuf::service::media::shared::message::VideoFrameRateType::_60);
|
||||||
|
|
||||||
if(ui_->radioButton480p->isChecked())
|
if(ui_->radioButton480p->isChecked())
|
||||||
{
|
{
|
||||||
configuration_->setVideoResolution(aasdk::proto::enums::VideoResolution::_480p);
|
configuration_->setVideoResolution(aap_protobuf::service::media::shared::message::VideoCodecResolutionType_480p);
|
||||||
}
|
}
|
||||||
else if(ui_->radioButton720p->isChecked())
|
else if(ui_->radioButton720p->isChecked())
|
||||||
{
|
{
|
||||||
configuration_->setVideoResolution(aasdk::proto::enums::VideoResolution::_720p);
|
configuration_->setVideoResolution(aap_protobuf::service::media::shared::message::VideoCodecResolutionType_720p);
|
||||||
}
|
}
|
||||||
else if(ui_->radioButton1080p->isChecked())
|
else if(ui_->radioButton1080p->isChecked())
|
||||||
{
|
{
|
||||||
configuration_->setVideoResolution(aasdk::proto::enums::VideoResolution::_1080p);
|
configuration_->setVideoResolution(aap_protobuf::service::media::shared::message::VideoCodecResolutionType_1080p);
|
||||||
}
|
}
|
||||||
|
|
||||||
configuration_->setScreenDPI(static_cast<size_t>(ui_->horizontalSliderScreenDPI->value()));
|
configuration_->setScreenDPI(static_cast<size_t>(ui_->horizontalSliderScreenDPI->value()));
|
||||||
@ -502,12 +502,12 @@ void SettingsWindow::load()
|
|||||||
ui_->checkBoxInstantPlay->setChecked(configuration_->instantPlay());
|
ui_->checkBoxInstantPlay->setChecked(configuration_->instantPlay());
|
||||||
ui_->checkBoxDontShowAgain->setChecked(configuration_->hideWarning());
|
ui_->checkBoxDontShowAgain->setChecked(configuration_->hideWarning());
|
||||||
|
|
||||||
ui_->radioButton30FPS->setChecked(configuration_->getVideoFPS() == aasdk::proto::enums::VideoFPS::_30);
|
ui_->radioButton30FPS->setChecked(configuration_->getVideoFPS() == aap_protobuf::service::media::shared::message::VideoFrameRateType::_30);
|
||||||
ui_->radioButton60FPS->setChecked(configuration_->getVideoFPS() == aasdk::proto::enums::VideoFPS::_60);
|
ui_->radioButton60FPS->setChecked(configuration_->getVideoFPS() == aap_protobuf::service::media::shared::message::VideoFrameRateType::_60);
|
||||||
|
|
||||||
ui_->radioButton480p->setChecked(configuration_->getVideoResolution() == aasdk::proto::enums::VideoResolution::_480p);
|
ui_->radioButton480p->setChecked(configuration_->getVideoResolution() == aap_protobuf::service::media::shared::message::VideoCodecResolutionType_480p);
|
||||||
ui_->radioButton720p->setChecked(configuration_->getVideoResolution() == aasdk::proto::enums::VideoResolution::_720p);
|
ui_->radioButton720p->setChecked(configuration_->getVideoResolution() == aap_protobuf::service::media::shared::message::VideoCodecResolutionType_720p);
|
||||||
ui_->radioButton1080p->setChecked(configuration_->getVideoResolution() == aasdk::proto::enums::VideoResolution::_1080p);
|
ui_->radioButton1080p->setChecked(configuration_->getVideoResolution() == aap_protobuf::service::media::shared::message::VideoCodecResolutionType_1080p);
|
||||||
ui_->horizontalSliderScreenDPI->setValue(static_cast<int>(configuration_->getScreenDPI()));
|
ui_->horizontalSliderScreenDPI->setValue(static_cast<int>(configuration_->getScreenDPI()));
|
||||||
ui_->spinBoxOmxLayerIndex->setValue(configuration_->getOMXLayerIndex());
|
ui_->spinBoxOmxLayerIndex->setValue(configuration_->getOMXLayerIndex());
|
||||||
|
|
||||||
@ -549,23 +549,23 @@ void SettingsWindow::load()
|
|||||||
void SettingsWindow::loadButtonCheckBoxes()
|
void SettingsWindow::loadButtonCheckBoxes()
|
||||||
{
|
{
|
||||||
const auto& buttonCodes = configuration_->getButtonCodes();
|
const auto& buttonCodes = configuration_->getButtonCodes();
|
||||||
ui_->checkBoxPlayButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aasdk::proto::enums::ButtonCode::PLAY) != buttonCodes.end());
|
ui_->checkBoxPlayButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_PLAY) != buttonCodes.end());
|
||||||
ui_->checkBoxPauseButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aasdk::proto::enums::ButtonCode::PAUSE) != buttonCodes.end());
|
ui_->checkBoxPauseButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_PAUSE) != buttonCodes.end());
|
||||||
ui_->checkBoxTogglePlayButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aasdk::proto::enums::ButtonCode::TOGGLE_PLAY) != buttonCodes.end());
|
ui_->checkBoxTogglePlayButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_PLAY_PAUSE) != buttonCodes.end());
|
||||||
ui_->checkBoxNextTrackButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aasdk::proto::enums::ButtonCode::NEXT) != buttonCodes.end());
|
ui_->checkBoxNextTrackButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_NEXT) != buttonCodes.end());
|
||||||
ui_->checkBoxPreviousTrackButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aasdk::proto::enums::ButtonCode::PREV) != buttonCodes.end());
|
ui_->checkBoxPreviousTrackButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_PREVIOUS) != buttonCodes.end());
|
||||||
ui_->checkBoxHomeButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aasdk::proto::enums::ButtonCode::HOME) != buttonCodes.end());
|
ui_->checkBoxHomeButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_HOME) != buttonCodes.end());
|
||||||
ui_->checkBoxPhoneButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aasdk::proto::enums::ButtonCode::PHONE) != buttonCodes.end());
|
ui_->checkBoxPhoneButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_CALL) != buttonCodes.end());
|
||||||
ui_->checkBoxCallEndButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aasdk::proto::enums::ButtonCode::CALL_END) != buttonCodes.end());
|
ui_->checkBoxCallEndButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_ENDCALL) != buttonCodes.end());
|
||||||
ui_->checkBoxVoiceCommandButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aasdk::proto::enums::ButtonCode::MICROPHONE_1) != buttonCodes.end());
|
ui_->checkBoxVoiceCommandButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_SEARCH) != buttonCodes.end());
|
||||||
ui_->checkBoxLeftButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aasdk::proto::enums::ButtonCode::LEFT) != buttonCodes.end());
|
ui_->checkBoxLeftButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_LEFT) != buttonCodes.end());
|
||||||
ui_->checkBoxRightButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aasdk::proto::enums::ButtonCode::RIGHT) != buttonCodes.end());
|
ui_->checkBoxRightButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_RIGHT) != buttonCodes.end());
|
||||||
ui_->checkBoxUpButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aasdk::proto::enums::ButtonCode::UP) != buttonCodes.end());
|
ui_->checkBoxUpButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_UP) != buttonCodes.end());
|
||||||
ui_->checkBoxDownButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aasdk::proto::enums::ButtonCode::DOWN) != buttonCodes.end());
|
ui_->checkBoxDownButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_DOWN) != buttonCodes.end());
|
||||||
ui_->checkBoxScrollWheelButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aasdk::proto::enums::ButtonCode::SCROLL_WHEEL) != buttonCodes.end());
|
ui_->checkBoxScrollWheelButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_ROTARY_CONTROLLER) != buttonCodes.end());
|
||||||
ui_->checkBoxBackButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aasdk::proto::enums::ButtonCode::BACK) != buttonCodes.end());
|
ui_->checkBoxBackButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_BACK) != buttonCodes.end());
|
||||||
ui_->checkBoxEnterButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aasdk::proto::enums::ButtonCode::ENTER) != buttonCodes.end());
|
ui_->checkBoxEnterButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_CENTER) != buttonCodes.end());
|
||||||
ui_->checkBoxNavButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aasdk::proto::enums::ButtonCode::NAVIGATION) != buttonCodes.end());
|
ui_->checkBoxNavButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_NAVIGATION) != buttonCodes.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsWindow::setButtonCheckBoxes(bool value)
|
void SettingsWindow::setButtonCheckBoxes(bool value)
|
||||||
@ -592,27 +592,27 @@ void SettingsWindow::setButtonCheckBoxes(bool value)
|
|||||||
void SettingsWindow::saveButtonCheckBoxes()
|
void SettingsWindow::saveButtonCheckBoxes()
|
||||||
{
|
{
|
||||||
configuration::IConfiguration::ButtonCodes buttonCodes;
|
configuration::IConfiguration::ButtonCodes buttonCodes;
|
||||||
this->saveButtonCheckBox(ui_->checkBoxPlayButton, buttonCodes, aasdk::proto::enums::ButtonCode::PLAY);
|
this->saveButtonCheckBox(ui_->checkBoxPlayButton, buttonCodes, aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_PLAY);
|
||||||
this->saveButtonCheckBox(ui_->checkBoxPauseButton, buttonCodes, aasdk::proto::enums::ButtonCode::PAUSE);
|
this->saveButtonCheckBox(ui_->checkBoxPauseButton, buttonCodes, aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_PAUSE);
|
||||||
this->saveButtonCheckBox(ui_->checkBoxTogglePlayButton, buttonCodes, aasdk::proto::enums::ButtonCode::TOGGLE_PLAY);
|
this->saveButtonCheckBox(ui_->checkBoxTogglePlayButton, buttonCodes, aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_PLAY_PAUSE);
|
||||||
this->saveButtonCheckBox(ui_->checkBoxNextTrackButton, buttonCodes, aasdk::proto::enums::ButtonCode::NEXT);
|
this->saveButtonCheckBox(ui_->checkBoxNextTrackButton, buttonCodes, aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_NEXT);
|
||||||
this->saveButtonCheckBox(ui_->checkBoxPreviousTrackButton, buttonCodes, aasdk::proto::enums::ButtonCode::PREV);
|
this->saveButtonCheckBox(ui_->checkBoxPreviousTrackButton, buttonCodes, aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_PREVIOUS);
|
||||||
this->saveButtonCheckBox(ui_->checkBoxHomeButton, buttonCodes, aasdk::proto::enums::ButtonCode::HOME);
|
this->saveButtonCheckBox(ui_->checkBoxHomeButton, buttonCodes, aap_protobuf::service::media::sink::KeyCode::KEYCODE_HOME);
|
||||||
this->saveButtonCheckBox(ui_->checkBoxPhoneButton, buttonCodes, aasdk::proto::enums::ButtonCode::PHONE);
|
this->saveButtonCheckBox(ui_->checkBoxPhoneButton, buttonCodes, aap_protobuf::service::media::sink::KeyCode::KEYCODE_CALL);
|
||||||
this->saveButtonCheckBox(ui_->checkBoxCallEndButton, buttonCodes, aasdk::proto::enums::ButtonCode::CALL_END);
|
this->saveButtonCheckBox(ui_->checkBoxCallEndButton, buttonCodes, aap_protobuf::service::media::sink::KeyCode::KEYCODE_ENDCALL);
|
||||||
this->saveButtonCheckBox(ui_->checkBoxVoiceCommandButton, buttonCodes, aasdk::proto::enums::ButtonCode::MICROPHONE_1);
|
this->saveButtonCheckBox(ui_->checkBoxVoiceCommandButton, buttonCodes, aap_protobuf::service::media::sink::KeyCode::KEYCODE_SEARCH);
|
||||||
this->saveButtonCheckBox(ui_->checkBoxLeftButton, buttonCodes, aasdk::proto::enums::ButtonCode::LEFT);
|
this->saveButtonCheckBox(ui_->checkBoxLeftButton, buttonCodes, aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_LEFT);
|
||||||
this->saveButtonCheckBox(ui_->checkBoxRightButton, buttonCodes, aasdk::proto::enums::ButtonCode::RIGHT);
|
this->saveButtonCheckBox(ui_->checkBoxRightButton, buttonCodes, aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_RIGHT);
|
||||||
this->saveButtonCheckBox(ui_->checkBoxUpButton, buttonCodes, aasdk::proto::enums::ButtonCode::UP);
|
this->saveButtonCheckBox(ui_->checkBoxUpButton, buttonCodes, aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_UP);
|
||||||
this->saveButtonCheckBox(ui_->checkBoxDownButton, buttonCodes, aasdk::proto::enums::ButtonCode::DOWN);
|
this->saveButtonCheckBox(ui_->checkBoxDownButton, buttonCodes, aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_DOWN);
|
||||||
this->saveButtonCheckBox(ui_->checkBoxScrollWheelButton, buttonCodes, aasdk::proto::enums::ButtonCode::SCROLL_WHEEL);
|
this->saveButtonCheckBox(ui_->checkBoxScrollWheelButton, buttonCodes, aap_protobuf::service::media::sink::KeyCode::KEYCODE_ROTARY_CONTROLLER);
|
||||||
this->saveButtonCheckBox(ui_->checkBoxBackButton, buttonCodes, aasdk::proto::enums::ButtonCode::BACK);
|
this->saveButtonCheckBox(ui_->checkBoxBackButton, buttonCodes, aap_protobuf::service::media::sink::KeyCode::KEYCODE_BACK);
|
||||||
this->saveButtonCheckBox(ui_->checkBoxEnterButton, buttonCodes, aasdk::proto::enums::ButtonCode::ENTER);
|
this->saveButtonCheckBox(ui_->checkBoxEnterButton, buttonCodes, aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_CENTER);
|
||||||
this->saveButtonCheckBox(ui_->checkBoxNavButton, buttonCodes, aasdk::proto::enums::ButtonCode::NAVIGATION);
|
this->saveButtonCheckBox(ui_->checkBoxNavButton, buttonCodes, aap_protobuf::service::media::sink::KeyCode::KEYCODE_NAVIGATION);
|
||||||
configuration_->setButtonCodes(buttonCodes);
|
configuration_->setButtonCodes(buttonCodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingsWindow::saveButtonCheckBox(const QCheckBox* checkBox, configuration::IConfiguration::ButtonCodes& buttonCodes, aasdk::proto::enums::ButtonCode::Enum buttonCode)
|
void SettingsWindow::saveButtonCheckBox(const QCheckBox* checkBox, configuration::IConfiguration::ButtonCodes& buttonCodes, aap_protobuf::service::media::sink::KeyCode buttonCode)
|
||||||
{
|
{
|
||||||
if(checkBox->isChecked())
|
if(checkBox->isChecked())
|
||||||
{
|
{
|
||||||
|
@ -19,12 +19,12 @@
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
#include <f1x/aasdk/USB/USBHub.hpp>
|
#include <aasdk/USB/USBHub.hpp>
|
||||||
#include <f1x/aasdk/USB/ConnectedAccessoriesEnumerator.hpp>
|
#include <aasdk/USB/ConnectedAccessoriesEnumerator.hpp>
|
||||||
#include <f1x/aasdk/USB/AccessoryModeQueryChain.hpp>
|
#include <aasdk/USB/AccessoryModeQueryChain.hpp>
|
||||||
#include <f1x/aasdk/USB/AccessoryModeQueryChainFactory.hpp>
|
#include <aasdk/USB/AccessoryModeQueryChainFactory.hpp>
|
||||||
#include <f1x/aasdk/USB/AccessoryModeQueryFactory.hpp>
|
#include <aasdk/USB/AccessoryModeQueryFactory.hpp>
|
||||||
#include <f1x/aasdk/TCP/TCPWrapper.hpp>
|
#include <aasdk/TCP/TCPWrapper.hpp>
|
||||||
#include <f1x/openauto/autoapp/App.hpp>
|
#include <f1x/openauto/autoapp/App.hpp>
|
||||||
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
||||||
#include <f1x/openauto/autoapp/Configuration/RecentAddressesList.hpp>
|
#include <f1x/openauto/autoapp/Configuration/RecentAddressesList.hpp>
|
||||||
@ -38,7 +38,7 @@
|
|||||||
#include <f1x/openauto/autoapp/UI/UpdateDialog.hpp>
|
#include <f1x/openauto/autoapp/UI/UpdateDialog.hpp>
|
||||||
#include <f1x/openauto/Common/Log.hpp>
|
#include <f1x/openauto/Common/Log.hpp>
|
||||||
|
|
||||||
namespace aasdk = f1x::aasdk;
|
namespace aasdk = aasdk;
|
||||||
namespace autoapp = f1x::openauto::autoapp;
|
namespace autoapp = f1x::openauto::autoapp;
|
||||||
using ThreadPool = std::vector<std::thread>;
|
using ThreadPool = std::vector<std::thread>;
|
||||||
|
|
||||||
|
@ -23,9 +23,6 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QtCore/QDataStream>
|
#include <QtCore/QDataStream>
|
||||||
#include <QNetworkInterface>
|
#include <QNetworkInterface>
|
||||||
#include <aasdk_proto/WifiInfoRequestMessage.pb.h>
|
|
||||||
#include <aasdk_proto/WifiInfoResponseMessage.pb.h>
|
|
||||||
#include <aasdk_proto/WifiSecurityResponseMessage.pb.h>
|
|
||||||
|
|
||||||
namespace f1x {
|
namespace f1x {
|
||||||
namespace openauto {
|
namespace openauto {
|
||||||
@ -61,11 +58,11 @@ namespace f1x {
|
|||||||
// connect(socket, &QBluetoothSocket::disconnected, this,
|
// connect(socket, &QBluetoothSocket::disconnected, this,
|
||||||
// QOverload<>::of(&ChatServer::clientDisconnected));
|
// QOverload<>::of(&ChatServer::clientDisconnected));
|
||||||
|
|
||||||
f1x::aasdk::proto::messages::WifiInfoRequest request;
|
//aap_protobuf::messages::WifiInfoRequest request;
|
||||||
request.set_ip_address(getIP4_("wlan0"));
|
//request.set_ip_address(getIP4_("wlan0"));
|
||||||
request.set_port(5000);
|
//request.set_port(5000);
|
||||||
|
|
||||||
sendMessage(request, 1);
|
//sendMessage(request, 1);
|
||||||
} else {
|
} else {
|
||||||
OPENAUTO_LOG(error) << "[AndroidBluetoothServer] received null socket during client connection.";
|
OPENAUTO_LOG(error) << "[AndroidBluetoothServer] received null socket during client connection.";
|
||||||
}
|
}
|
||||||
@ -93,7 +90,7 @@ namespace f1x {
|
|||||||
uint16_t messageId;
|
uint16_t messageId;
|
||||||
stream >> messageId;
|
stream >> messageId;
|
||||||
|
|
||||||
//OPENAUTO_LOG(info) << "[AndroidBluetoothServer] " << length << " " << messageId;
|
OPENAUTO_LOG(debug) << "";
|
||||||
|
|
||||||
switch (messageId) {
|
switch (messageId) {
|
||||||
case 1:
|
case 1:
|
||||||
@ -121,28 +118,30 @@ namespace f1x {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AndroidBluetoothServer::handleWifiInfoRequest(QByteArray &buffer, uint16_t length) {
|
void AndroidBluetoothServer::handleWifiInfoRequest(QByteArray &buffer, uint16_t length) {
|
||||||
f1x::aasdk::proto::messages::WifiInfoRequest msg;
|
//TODO: Restire
|
||||||
msg.ParseFromArray(buffer.data() + 4, length);
|
//aap_protobuf::messages::WifiInfoRequest msg;
|
||||||
OPENAUTO_LOG(info) << "WifiInfoRequest: " << msg.DebugString();
|
//msg.ParseFromArray(buffer.data() + 4, length);
|
||||||
|
OPENAUTO_LOG(info) << "[AndroidBluetoothServer] WifiInfoRequest: "; //<< msg.DebugString();
|
||||||
|
|
||||||
f1x::aasdk::proto::messages::WifiInfoResponse response;
|
//aap_protobuf::messages::WifiInfoResponse response;
|
||||||
response.set_ip_address(getIP4_("wlan0"));
|
//response.set_ip_address(getIP4_("wlan0"));
|
||||||
response.set_port(5000);
|
//response.set_port(5000);
|
||||||
response.set_status(aasdk::proto::messages::WifiInfoResponse_Status_STATUS_SUCCESS);
|
//response.set_status(aap_protobuf::messages::WifiInfoResponse_Status_STATUS_SUCCESS);
|
||||||
|
|
||||||
sendMessage(response, 7);
|
//sendMessage(response, 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidBluetoothServer::handleWifiSecurityRequest(QByteArray &buffer, uint16_t length) {
|
void AndroidBluetoothServer::handleWifiSecurityRequest(QByteArray &buffer, uint16_t length) {
|
||||||
f1x::aasdk::proto::messages::WifiSecurityReponse response;
|
OPENAUTO_LOG(info) << "[AndroidBluetoothServer] WifiSecurityRequest:";
|
||||||
|
//aap_protobuf::messages::WifiSecurityReponse response;
|
||||||
|
|
||||||
response.set_ssid(configuration_->getParamFromFile("/etc/hostapd/hostapd.conf","ssid").toStdString());
|
//response.set_ssid(configuration_->getParamFromFile("/etc/hostapd/hostapd.conf","ssid").toStdString());
|
||||||
response.set_bssid(QNetworkInterface::interfaceFromName("wlan0").hardwareAddress().toStdString());
|
//response.set_bssid(QNetworkInterface::interfaceFromName("wlan0").hardwareAddress().toStdString());
|
||||||
response.set_key(configuration_->getParamFromFile("/etc/hostapd/hostapd.conf","wpa_passphrase").toStdString());
|
//response.set_key(configuration_->getParamFromFile("/etc/hostapd/hostapd.conf","wpa_passphrase").toStdString());
|
||||||
response.set_security_mode(aasdk::proto::messages::WifiSecurityReponse_SecurityMode_WPA2_PERSONAL);
|
//response.set_security_mode(aap_protobuf::messages::WifiSecurityReponse_SecurityMode_WPA2_PERSONAL);
|
||||||
response.set_access_point_type(aasdk::proto::messages::WifiSecurityReponse_AccessPointType_STATIC);
|
//response.set_access_point_type(aap_protobuf::messages::WifiSecurityReponse_AccessPointType_STATIC);
|
||||||
|
|
||||||
sendMessage(response, 3);
|
//sendMessage(response, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidBluetoothServer::sendMessage(const google::protobuf::Message& message, uint16_t type) {
|
void AndroidBluetoothServer::sendMessage(const google::protobuf::Message& message, uint16_t type) {
|
||||||
@ -170,9 +169,10 @@ namespace f1x {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AndroidBluetoothServer::handleWifiInfoRequestResponse(QByteArray &buffer, uint16_t length) {
|
void AndroidBluetoothServer::handleWifiInfoRequestResponse(QByteArray &buffer, uint16_t length) {
|
||||||
f1x::aasdk::proto::messages::WifiInfoResponse msg;
|
OPENAUTO_LOG(info) << "[AndroidBluetoothServer] WifiInfoRequestResponse";
|
||||||
msg.ParseFromArray(buffer.data() + 4, length);
|
//aap_protobuf::messages::WifiInfoResponse msg;
|
||||||
OPENAUTO_LOG(info) << "WifiInfoResponse: " << msg.DebugString();
|
//msg.ParseFromArray(buffer.data() + 4, length);
|
||||||
|
//OPENAUTO_LOG(info) << "WifiInfoResponse: " << msg.DebugString();
|
||||||
}
|
}
|
||||||
|
|
||||||
const ::std::string AndroidBluetoothServer::getIP4_(const QString intf) {
|
const ::std::string AndroidBluetoothServer::getIP4_(const QString intf) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user