From 5a2a305c04fd862b4fa712a9356d15efce576593 Mon Sep 17 00:00:00 2001 From: Simon Dean Date: Mon, 4 Nov 2024 13:51:11 +0000 Subject: [PATCH] All modifications for AAP 1.6 --- CMakeLists.txt | 156 +++++----- Dockerfile | 3 + include/f1x/openauto/autoapp/App.hpp | 10 +- .../autoapp/Configuration/Configuration.hpp | 43 ++- .../autoapp/Configuration/IConfiguration.hpp | 24 +- .../autoapp/Projection/IAudioInput.hpp | 4 +- .../autoapp/Projection/IAudioOutput.hpp | 4 +- .../autoapp/Projection/IBluetoothDevice.hpp | 2 +- .../autoapp/Projection/IInputDevice.hpp | 4 +- .../autoapp/Projection/IVideoOutput.hpp | 14 +- .../autoapp/Projection/InputEvent.hpp | 10 +- .../autoapp/Projection/SequentialBuffer.hpp | 2 +- .../autoapp/Projection/VideoOutput.hpp | 4 +- .../autoapp/Service/AndroidAutoEntity.hpp | 25 +- .../Service/AndroidAutoEntityFactory.hpp | 2 +- .../autoapp/Service/AudioInputService.hpp | 67 ----- .../openauto/autoapp/Service/AudioService.hpp | 67 ----- .../Service/Bluetooth/BluetoothService.hpp | 66 +++++ .../autoapp/Service/BluetoothService.hpp | 58 ---- .../GenericNotificationService.hpp | 61 ++++ .../IAndroidAutoEntityEventHandler.hpp | 2 +- .../Service/IAndroidAutoEntityFactory.hpp | 4 +- .../f1x/openauto/autoapp/Service/IPinger.hpp | 2 +- .../f1x/openauto/autoapp/Service/IService.hpp | 6 +- .../autoapp/Service/IServiceFactory.hpp | 2 +- .../openauto/autoapp/Service/InputService.hpp | 67 ----- .../InputSource/InputSourceService.hpp | 71 +++++ .../MediaBrowser/MediaBrowserService.hpp | 61 ++++ .../MediaPlaybackStatusService.hpp | 61 ++++ .../MediaSink/AudioMediaSinkService.hpp | 78 +++++ .../GuidanceAudioService.hpp} | 37 ++- .../{ => MediaSink}/MediaAudioService.hpp | 37 ++- .../Service/MediaSink/SystemAudioService.hpp | 39 +-- .../MediaSink/TelephonyAudioService.hpp | 44 +++ .../MediaSink/VideoMediaSinkService.hpp | 82 ++++++ .../VideoService.hpp} | 40 +-- .../MediaSource/MediaSourceService.hpp | 91 ++++++ .../MicrophoneMediaSourceService.hpp | 44 +++ .../NavigationStatusService.hpp | 61 ++++ .../PhoneStatus/PhoneStatusService.hpp | 61 ++++ .../autoapp/Service/Radio/RadioService.hpp | 61 ++++ .../autoapp/Service/Sensor/SensorService.hpp | 83 ++++++ .../autoapp/Service/SensorService.hpp | 70 ----- .../Service/{WifiService.hpp => Service.hpp} | 56 ++-- .../autoapp/Service/ServiceFactory.hpp | 54 ++-- .../VendorExtensionService.hpp | 61 ++++ .../openauto/autoapp/Service/VideoService.hpp | 70 ----- .../WifiProjection/WifiProjectionService.hpp | 63 ++++ .../f1x/openauto/autoapp/UI/ConnectDialog.hpp | 4 +- .../openauto/autoapp/UI/SettingsWindow.hpp | 3 +- .../btservice/AndroidBluetoothServer.hpp | 2 +- src/autoapp/App.cpp | 4 +- src/autoapp/Configuration/Configuration.cpp | 154 ++++++---- src/autoapp/Projection/InputDevice.cpp | 48 ++-- src/autoapp/Projection/OMXVideoOutput.cpp | 2 +- src/autoapp/Projection/RtAudioOutput.cpp | 36 ++- src/autoapp/Projection/VideoOutput.cpp | 4 +- src/autoapp/Service/AndroidAutoEntity.cpp | 154 +++++++--- .../Service/AndroidAutoEntityFactory.cpp | 16 +- src/autoapp/Service/AudioInputService.cpp | 215 -------------- src/autoapp/Service/AudioService.cpp | 196 ------------- .../Service/Bluetooth/BluetoothService.cpp | 122 ++++++++ src/autoapp/Service/BluetoothService.cpp | 127 -------- .../GenericNotificationService.cpp | 79 +++++ src/autoapp/Service/InputService.cpp | 205 ------------- .../InputSource/InputSourceService.cpp | 196 +++++++++++++ .../MediaBrowser/MediaBrowserService.cpp | 79 +++++ .../MediaPlaybackStatusService.cpp | 79 +++++ .../MediaSink/AudioMediaSinkService.cpp | 217 ++++++++++++++ .../MediaSink/GuidanceAudioService.cpp | 43 +++ .../Service/MediaSink/MediaAudioService.cpp | 42 +++ .../Service/MediaSink/SystemAudioService.cpp | 42 +++ .../MediaSink/TelephonyAudioService.cpp | 41 +++ .../MediaSink/VideoMediaSinkService.cpp | 208 ++++++++++++++ .../Service/MediaSink/VideoService.cpp | 41 +++ .../MediaSource/MediaSourceService.cpp | 272 ++++++++++++++++++ .../NavigationStatusService.cpp | 79 +++++ .../PhoneStatus/PhoneStatusService.cpp | 81 ++++++ src/autoapp/Service/Radio/RadioService.cpp | 81 ++++++ src/autoapp/Service/Sensor/SensorService.cpp | 246 ++++++++++++++++ src/autoapp/Service/SensorService.cpp | 261 ----------------- src/autoapp/Service/ServiceFactory.cpp | 258 ++++++++++------- src/autoapp/Service/SpeechAudioService.cpp | 40 --- src/autoapp/Service/SystemAudioService.cpp | 40 --- .../VendorExtensionService.cpp | 81 ++++++ src/autoapp/Service/VideoService.cpp | 214 -------------- .../WifiProjection/WifiProjectionStatus.cpp | 103 +++++++ src/autoapp/Service/WifiService.cpp | 69 ----- src/autoapp/UI/SettingsWindow.cpp | 88 +++--- src/autoapp/autoapp.cpp | 14 +- src/btservice/AndroidBluetoothServer.cpp | 52 ++-- 91 files changed, 4012 insertions(+), 2360 deletions(-) create mode 100644 Dockerfile delete mode 100644 include/f1x/openauto/autoapp/Service/AudioInputService.hpp delete mode 100644 include/f1x/openauto/autoapp/Service/AudioService.hpp create mode 100644 include/f1x/openauto/autoapp/Service/Bluetooth/BluetoothService.hpp delete mode 100644 include/f1x/openauto/autoapp/Service/BluetoothService.hpp create mode 100644 include/f1x/openauto/autoapp/Service/GenericNotification/GenericNotificationService.hpp delete mode 100644 include/f1x/openauto/autoapp/Service/InputService.hpp create mode 100644 include/f1x/openauto/autoapp/Service/InputSource/InputSourceService.hpp create mode 100644 include/f1x/openauto/autoapp/Service/MediaBrowser/MediaBrowserService.hpp create mode 100644 include/f1x/openauto/autoapp/Service/MediaPlaybackStatus/MediaPlaybackStatusService.hpp create mode 100644 include/f1x/openauto/autoapp/Service/MediaSink/AudioMediaSinkService.hpp rename include/f1x/openauto/autoapp/Service/{SystemAudioService.hpp => MediaSink/GuidanceAudioService.hpp} (54%) rename include/f1x/openauto/autoapp/Service/{ => MediaSink}/MediaAudioService.hpp (54%) rename src/autoapp/Service/MediaAudioService.cpp => include/f1x/openauto/autoapp/Service/MediaSink/SystemAudioService.hpp (50%) create mode 100644 include/f1x/openauto/autoapp/Service/MediaSink/TelephonyAudioService.hpp create mode 100644 include/f1x/openauto/autoapp/Service/MediaSink/VideoMediaSinkService.hpp rename include/f1x/openauto/autoapp/Service/{SpeechAudioService.hpp => MediaSink/VideoService.hpp} (52%) create mode 100644 include/f1x/openauto/autoapp/Service/MediaSource/MediaSourceService.hpp create mode 100644 include/f1x/openauto/autoapp/Service/MediaSource/MicrophoneMediaSourceService.hpp create mode 100644 include/f1x/openauto/autoapp/Service/NavigationStatus/NavigationStatusService.hpp create mode 100644 include/f1x/openauto/autoapp/Service/PhoneStatus/PhoneStatusService.hpp create mode 100644 include/f1x/openauto/autoapp/Service/Radio/RadioService.hpp create mode 100644 include/f1x/openauto/autoapp/Service/Sensor/SensorService.hpp delete mode 100644 include/f1x/openauto/autoapp/Service/SensorService.hpp rename include/f1x/openauto/autoapp/Service/{WifiService.hpp => Service.hpp} (50%) create mode 100644 include/f1x/openauto/autoapp/Service/VendorExtension/VendorExtensionService.hpp delete mode 100644 include/f1x/openauto/autoapp/Service/VideoService.hpp create mode 100644 include/f1x/openauto/autoapp/Service/WifiProjection/WifiProjectionService.hpp delete mode 100644 src/autoapp/Service/AudioInputService.cpp delete mode 100644 src/autoapp/Service/AudioService.cpp create mode 100644 src/autoapp/Service/Bluetooth/BluetoothService.cpp delete mode 100644 src/autoapp/Service/BluetoothService.cpp create mode 100644 src/autoapp/Service/GenericNotification/GenericNotificationService.cpp delete mode 100644 src/autoapp/Service/InputService.cpp create mode 100644 src/autoapp/Service/InputSource/InputSourceService.cpp create mode 100644 src/autoapp/Service/MediaBrowser/MediaBrowserService.cpp create mode 100644 src/autoapp/Service/MediaPlaybackStatus/MediaPlaybackStatusService.cpp create mode 100644 src/autoapp/Service/MediaSink/AudioMediaSinkService.cpp create mode 100644 src/autoapp/Service/MediaSink/GuidanceAudioService.cpp create mode 100644 src/autoapp/Service/MediaSink/MediaAudioService.cpp create mode 100644 src/autoapp/Service/MediaSink/SystemAudioService.cpp create mode 100644 src/autoapp/Service/MediaSink/TelephonyAudioService.cpp create mode 100644 src/autoapp/Service/MediaSink/VideoMediaSinkService.cpp create mode 100644 src/autoapp/Service/MediaSink/VideoService.cpp create mode 100644 src/autoapp/Service/MediaSource/MediaSourceService.cpp create mode 100644 src/autoapp/Service/NavigationStatus/NavigationStatusService.cpp create mode 100644 src/autoapp/Service/PhoneStatus/PhoneStatusService.cpp create mode 100644 src/autoapp/Service/Radio/RadioService.cpp create mode 100644 src/autoapp/Service/Sensor/SensorService.cpp delete mode 100644 src/autoapp/Service/SensorService.cpp delete mode 100644 src/autoapp/Service/SpeechAudioService.cpp delete mode 100644 src/autoapp/Service/SystemAudioService.cpp create mode 100644 src/autoapp/Service/VendorExtension/VendorExtensionService.cpp delete mode 100644 src/autoapp/Service/VideoService.cpp create mode 100644 src/autoapp/Service/WifiProjection/WifiProjectionStatus.cpp delete mode 100644 src/autoapp/Service/WifiService.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 85a64be..4499c9a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,98 +1,119 @@ cmake_minimum_required(VERSION 3.5.1) + project(openauto CXX) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTORCC ON) -set(base_directory ${CMAKE_CURRENT_SOURCE_DIR}) -set(resources_directory ${base_directory}/assets) -set(sources_directory ${base_directory}/src) -set(include_directory ${base_directory}/include) -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${base_directory}/lib) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${base_directory}/lib) +# Set Compile Versions +set(OPENAUTO_BUILD_DATE 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) -set(EXECUTABLE_OUTPUT_PATH ${base_directory}/bin) - -set(Boost_USE_STATIC_LIBS OFF) -set(Boost_USE_MULTITHREADED ON) -set(Boost_USE_STATIC_RUNTIME OFF) - -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake_modules/") -SET(CMAKE_CXX_STANDARD 14) +# Configure CMAKE +SET(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_INIT} -Wall -pedantic -fPIC") set(CMAKE_CXX_FLAGS_DEBUG "-g -O0") set(CMAKE_CXX_FLAGS_RELEASE "-g -O3") +# Paths +set(resources_directory ${CMAKE_CURRENT_SOURCE_DIR}/assets) +set(sources_directory ${CMAKE_CURRENT_SOURCE_DIR}/src) +set(include_directory ${CMAKE_CURRENT_SOURCE_DIR}/include) + +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin) +set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/bin) +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake_modules/") + +# Configure Boost +set(Boost_USE_STATIC_LIBS OFF) +set(Boost_USE_MULTITHREADED ON) +set(Boost_USE_STATIC_RUNTIME OFF) + add_definitions(-DBOOST_ALL_DYN_LINK) +if (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(libusb-1.0 REQUIRED) find_package(Qt5 COMPONENTS Multimedia MultimediaWidgets Bluetooth Network) -find_package(Protobuf REQUIRED) find_package(OpenSSL REQUIRED) find_package(rtaudio REQUIRED) find_package(taglib REQUIRED) find_package(blkid REQUIRED) find_package(gps REQUIRED) -if(WIN32) - set(WINSOCK2_LIBRARIES "ws2_32") -endif(WIN32) - -if(RPI3_BUILD) - add_definitions(-DUSE_OMX -DOMX_SKIP64BIT -DRASPBERRYPI3) - set(BCM_HOST_LIBRARIES "/opt/vc/lib/libbcm_host.so") - set(BCM_HOST_INCLUDE_DIRS "/opt/vc/include") - set(ILCLIENT_INCLUDE_DIRS "/opt/vc/src/hello_pi/libs/ilclient") - set(ILCLIENT_LIBRARIES "/opt/vc/src/hello_pi/libs/ilclient/libilclient.a;/opt/vc/lib/libvcos.so;/opt/vc/lib/libvcilcs.a;/opt/vc/lib/libvchiq_arm.so") -endif(RPI3_BUILD) - include_directories(${CMAKE_CURRENT_BINARY_DIR} - ${Qt5Multimedia_INCLUDE_DIRS} - ${Qt5MultimediaWidgets_INCLUDE_DIRS} - ${Qt5Widgets_INCLUDE_DIRS} - ${Qt5Bluetooth_INCLUDE_DIRS} - ${Qt5Network_INCLUDE_DIRS} - ${Boost_INCLUDE_DIRS} - ${PROTOBUF_INCLUDE_DIR} - ${OPENSSL_INCLUDE_DIR} - ${RTAUDIO_INCLUDE_DIRS} - ${TAGLIB_INCLUDE_DIRS} - ${BLKID_INCLUDE_DIRS} - ${AASDK_PROTO_INCLUDE_DIRS} - ${AASDK_INCLUDE_DIRS} - ${BCM_HOST_INCLUDE_DIRS} - ${ILCLIENT_INCLUDE_DIRS} - ${include_directory}) - + ${Qt5Multimedia_INCLUDE_DIRS} + ${Qt5MultimediaWidgets_INCLUDE_DIRS} + ${Qt5Widgets_INCLUDE_DIRS} + ${Qt5Bluetooth_INCLUDE_DIRS} + ${Qt5Network_INCLUDE_DIRS} + ${Boost_INCLUDE_DIRS} + ${PROTOBUF_INCLUDE_DIR} + ${AAP_PROTOBUF_INCLUDE_DIR} + ${OPENSSL_INCLUDE_DIR} + ${RTAUDIO_INCLUDE_DIRS} + ${TAGLIB_INCLUDE_DIRS} + ${BLKID_INCLUDE_DIRS} + ${BCM_HOST_INCLUDE_DIRS} + ${ILCLIENT_INCLUDE_DIRS} + ${include_directory}) + link_directories(${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) set(common_include_directory ${include_directory}/f1x/openauto/Common) set(autoapp_sources_directory ${sources_directory}/autoapp) set(autoapp_include_directory ${include_directory}/f1x/openauto/autoapp) + file(GLOB_RECURSE autoapp_source_files ${autoapp_sources_directory}/*.ui ${autoapp_sources_directory}/*.cpp ${autoapp_include_directory}/*.hpp ${common_include_directory}/*.hpp ${resources_directory}/*.qrc) add_executable(autoapp ${autoapp_source_files}) target_link_libraries(autoapp libusb - ${Boost_LIBRARIES} - ${Qt5Multimedia_LIBRARIES} - ${Qt5MultimediaWidgets_LIBRARIES} - ${Qt5Bluetooth_LIBRARIES} - ${Qt5Network_LIBRARIES} - ${PROTOBUF_LIBRARIES} - ${BCM_HOST_LIBRARIES} - ${ILCLIENT_LIBRARIES} - ${WINSOCK2_LIBRARIES} - ${RTAUDIO_LIBRARIES} - ${TAGLIB_LIBRARIES} - ${BLKID_LIBRARIES} - ${GPS_LIBRARIES} - ${AASDK_PROTO_LIBRARIES} - ${AASDK_LIBRARIES}) + aap_protobuf + aasdk + ${Boost_LIBRARIES} + ${Qt5Multimedia_LIBRARIES} + ${Qt5MultimediaWidgets_LIBRARIES} + ${Qt5Bluetooth_LIBRARIES} + ${Qt5Network_LIBRARIES} + ${PROTOBUF_LIBRARIES} + ${BCM_HOST_LIBRARIES} + ${ILCLIENT_LIBRARIES} + ${WINSOCK2_LIBRARIES} + ${RTAUDIO_LIBRARIES} + ${TAGLIB_LIBRARIES} + ${BLKID_LIBRARIES} + ${GPS_LIBRARIES}) set(btservice_sources_directory ${sources_directory}/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}) -target_link_libraries(btservice - ${Boost_LIBRARIES} - ${Qt5Bluetooth_LIBRARIES} - ${Qt5Network_LIBRARIES} - ${Qt5MultimediaWidgets_LIBRARIES} - ${PROTOBUF_LIBRARIES} - ${AASDK_PROTO_LIBRARIES}) +target_link_libraries( + btservice + aap_protobuf + ${Boost_LIBRARIES} + ${Qt5Bluetooth_LIBRARIES} + ${Qt5Network_LIBRARIES} + ${Qt5MultimediaWidgets_LIBRARIES} + ${PROTOBUF_LIBRARIES}) diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b17a21c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,3 @@ +FROM scratch +ADD rootfs.tar.xz / +CMD ["bash"] \ No newline at end of file diff --git a/include/f1x/openauto/autoapp/App.hpp b/include/f1x/openauto/autoapp/App.hpp index 4ecd245..0af1e18 100644 --- a/include/f1x/openauto/autoapp/App.hpp +++ b/include/f1x/openauto/autoapp/App.hpp @@ -18,11 +18,11 @@ #pragma once -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include diff --git a/include/f1x/openauto/autoapp/Configuration/Configuration.hpp b/include/f1x/openauto/autoapp/Configuration/Configuration.hpp index c908cc6..e077135 100644 --- a/include/f1x/openauto/autoapp/Configuration/Configuration.hpp +++ b/include/f1x/openauto/autoapp/Configuration/Configuration.hpp @@ -23,6 +23,7 @@ #include #include #include + #include namespace f1x @@ -88,10 +89,10 @@ public: QString readFileContent(QString fileName) const override; QString getParamFromFile(QString fileName, QString searchString) const override; - aasdk::proto::enums::VideoFPS::Enum getVideoFPS() const override; - void setVideoFPS(aasdk::proto::enums::VideoFPS::Enum value) override; - aasdk::proto::enums::VideoResolution::Enum getVideoResolution() const override; - void setVideoResolution(aasdk::proto::enums::VideoResolution::Enum value) override; + aap_protobuf::service::media::shared::message::VideoFrameRateType getVideoFPS() const override; + void setVideoFPS(aap_protobuf::service::media::shared::message::VideoFrameRateType value) override; + aap_protobuf::service::media::shared::message::VideoCodecResolutionType getVideoResolution() const override; + void setVideoResolution(aap_protobuf::service::media::shared::message::VideoCodecResolutionType value) override; size_t getScreenDPI() const override; void setScreenDPI(size_t value) override; void setOMXLayerIndex(int32_t value) override; @@ -113,14 +114,18 @@ public: bool musicAudioChannelEnabled() const override; void setMusicAudioChannelEnabled(bool value) override; - bool speechAudioChannelEnabled() const override; - void setSpeechAudioChannelEnabled(bool value) override; + bool guidanceAudioChannelEnabled() const override; + void setGuidanceAudioChannelEnabled(bool value) override; + bool systemAudioChannelEnabled() const override; + void setSystemAudioChannelEnabled(bool value) override; + bool telephonyAudioChannelEnabled() const override; + void setTelephonyAudioChannelEnabled(bool value) override; + AudioOutputBackendType getAudioOutputBackendType() const override; void setAudioOutputBackendType(AudioOutputBackendType value) override; - private: void readButtonCodes(boost::property_tree::ptree& iniConfig); - void insertButtonCode(boost::property_tree::ptree& iniConfig, const std::string& buttonCodeKey, aasdk::proto::enums::ButtonCode::Enum buttonCode); + void insertButtonCode(boost::property_tree::ptree& iniConfig, const std::string& buttonCodeKey, aap_protobuf::service::media::sink::KeyCode buttonCode); void writeButtonCodes(boost::property_tree::ptree& iniConfig); HandednessOfTrafficType handednessOfTrafficType_; @@ -143,8 +148,8 @@ private: bool showAutoPlay_; bool instantPlay_; - aasdk::proto::enums::VideoFPS::Enum videoFPS_; - aasdk::proto::enums::VideoResolution::Enum videoResolution_; + aap_protobuf::service::media::shared::message::VideoFrameRateType videoFPS_; + aap_protobuf::service::media::shared::message::VideoCodecResolutionType videoResolution_; size_t screenDPI_; int32_t omxLayerIndex_; QRect videoMargins_; @@ -153,8 +158,11 @@ private: ButtonCodes buttonCodes_; BluetoothAdapterType bluetoothAdapterType_; std::string bluetoothRemoteAdapterAddress_; - bool musicAudioChannelEnabled_; - bool speechAudiochannelEnabled_; + bool _audioChannelEnabledMedia; + bool _audioChannelEnabledGuidance; + bool _audioChannelEnabledSystem; + bool _audioChannelEnabledTelephony; + AudioOutputBackendType audioOutputBackendType_; static const std::string cConfigFileName; @@ -188,8 +196,15 @@ private: static const std::string cVideoMarginWidth; static const std::string cVideoMarginHeight; - static const std::string cAudioMusicAudioChannelEnabled; - static const std::string cAudioSpeechAudioChannelEnabled; + struct Audio { + 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 cBluetoothAdapterTypeKey; diff --git a/include/f1x/openauto/autoapp/Configuration/IConfiguration.hpp b/include/f1x/openauto/autoapp/Configuration/IConfiguration.hpp index db22bc8..a34678a 100644 --- a/include/f1x/openauto/autoapp/Configuration/IConfiguration.hpp +++ b/include/f1x/openauto/autoapp/Configuration/IConfiguration.hpp @@ -20,9 +20,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include #include #include @@ -40,7 +40,7 @@ class IConfiguration { public: typedef std::shared_ptr Pointer; - typedef std::vector ButtonCodes; + typedef std::vector ButtonCodes; virtual ~IConfiguration() = default; @@ -92,10 +92,10 @@ public: virtual QString readFileContent(QString fileName) const = 0; virtual QString getParamFromFile(QString fileName, QString searchString) const = 0; - virtual aasdk::proto::enums::VideoFPS::Enum getVideoFPS() const = 0; - virtual void setVideoFPS(aasdk::proto::enums::VideoFPS::Enum value) = 0; - virtual aasdk::proto::enums::VideoResolution::Enum getVideoResolution() const = 0; - virtual void setVideoResolution(aasdk::proto::enums::VideoResolution::Enum value) = 0; + virtual aap_protobuf::service::media::shared::message::VideoFrameRateType getVideoFPS() const = 0; + virtual void setVideoFPS(aap_protobuf::service::media::shared::message::VideoFrameRateType value) = 0; + virtual aap_protobuf::service::media::shared::message::VideoCodecResolutionType getVideoResolution() const = 0; + virtual void setVideoResolution(aap_protobuf::service::media::shared::message::VideoCodecResolutionType value) = 0; virtual size_t getScreenDPI() const = 0; virtual void setScreenDPI(size_t value) = 0; virtual void setOMXLayerIndex(int32_t value) = 0; @@ -117,8 +117,12 @@ public: virtual bool musicAudioChannelEnabled() const = 0; virtual void setMusicAudioChannelEnabled(bool value) = 0; - virtual bool speechAudioChannelEnabled() const = 0; - virtual void setSpeechAudioChannelEnabled(bool value) = 0; + virtual bool guidanceAudioChannelEnabled() const = 0; + virtual void setGuidanceAudioChannelEnabled(bool value) = 0; + virtual bool systemAudioChannelEnabled() const = 0; + virtual void setSystemAudioChannelEnabled(bool value) = 0; + virtual bool telephonyAudioChannelEnabled() const = 0; + virtual void setTelephonyAudioChannelEnabled(bool value) = 0; virtual AudioOutputBackendType getAudioOutputBackendType() const = 0; virtual void setAudioOutputBackendType(AudioOutputBackendType value) = 0; }; diff --git a/include/f1x/openauto/autoapp/Projection/IAudioInput.hpp b/include/f1x/openauto/autoapp/Projection/IAudioInput.hpp index 67c3373..a85d588 100644 --- a/include/f1x/openauto/autoapp/Projection/IAudioInput.hpp +++ b/include/f1x/openauto/autoapp/Projection/IAudioInput.hpp @@ -19,8 +19,8 @@ #pragma once #include -#include -#include +#include +#include namespace f1x { diff --git a/include/f1x/openauto/autoapp/Projection/IAudioOutput.hpp b/include/f1x/openauto/autoapp/Projection/IAudioOutput.hpp index c41de31..aaec03a 100644 --- a/include/f1x/openauto/autoapp/Projection/IAudioOutput.hpp +++ b/include/f1x/openauto/autoapp/Projection/IAudioOutput.hpp @@ -19,8 +19,8 @@ #pragma once #include -#include -#include +#include +#include namespace f1x { diff --git a/include/f1x/openauto/autoapp/Projection/IBluetoothDevice.hpp b/include/f1x/openauto/autoapp/Projection/IBluetoothDevice.hpp index 2d151fd..e5794cb 100644 --- a/include/f1x/openauto/autoapp/Projection/IBluetoothDevice.hpp +++ b/include/f1x/openauto/autoapp/Projection/IBluetoothDevice.hpp @@ -16,7 +16,7 @@ * along with openauto. If not, see . */ -#include +#include #pragma once diff --git a/include/f1x/openauto/autoapp/Projection/IInputDevice.hpp b/include/f1x/openauto/autoapp/Projection/IInputDevice.hpp index 663fbbd..dc97b2c 100644 --- a/include/f1x/openauto/autoapp/Projection/IInputDevice.hpp +++ b/include/f1x/openauto/autoapp/Projection/IInputDevice.hpp @@ -19,7 +19,7 @@ #pragma once #include -#include +#include #include namespace f1x @@ -37,7 +37,7 @@ class IInputDevice { public: typedef std::shared_ptr Pointer; - typedef std::vector ButtonCodes; + typedef std::vector ButtonCodes; virtual ~IInputDevice() = default; virtual void start(IInputDeviceEventHandler& eventHandler) = 0; diff --git a/include/f1x/openauto/autoapp/Projection/IVideoOutput.hpp b/include/f1x/openauto/autoapp/Projection/IVideoOutput.hpp index ef0f91c..668c329 100644 --- a/include/f1x/openauto/autoapp/Projection/IVideoOutput.hpp +++ b/include/f1x/openauto/autoapp/Projection/IVideoOutput.hpp @@ -20,9 +20,10 @@ #include #include -#include -#include -#include +#include +#include +#include +#include namespace f1x { @@ -43,13 +44,14 @@ public: virtual bool open() = 0; virtual bool init() = 0; - virtual void write(uint64_t timestamp, const aasdk::common::DataConstBuffer& buffer) = 0; + virtual void write(aasdk::messenger::Timestamp::ValueType timestamp, const aasdk::common::DataConstBuffer& buffer) = 0; virtual void stop() = 0; - virtual aasdk::proto::enums::VideoFPS::Enum getVideoFPS() const = 0; - virtual aasdk::proto::enums::VideoResolution::Enum getVideoResolution() const = 0; + virtual aap_protobuf::service::media::shared::message::VideoFrameRateType getVideoFPS() const = 0; + virtual aap_protobuf::service::media::shared::message::VideoCodecResolutionType getVideoResolution() const = 0; virtual size_t getScreenDPI() const = 0; virtual QRect getVideoMargins() const = 0; + }; } diff --git a/include/f1x/openauto/autoapp/Projection/InputEvent.hpp b/include/f1x/openauto/autoapp/Projection/InputEvent.hpp index fe22064..7e4f92a 100644 --- a/include/f1x/openauto/autoapp/Projection/InputEvent.hpp +++ b/include/f1x/openauto/autoapp/Projection/InputEvent.hpp @@ -18,9 +18,9 @@ #pragma once -#include -#include -#include +#include +#include +#include namespace f1x { @@ -49,12 +49,12 @@ struct ButtonEvent { ButtonEventType type; WheelDirection wheelDirection; - aasdk::proto::enums::ButtonCode::Enum code; + aap_protobuf::service::media::sink::KeyCode code; }; struct TouchEvent { - aasdk::proto::enums::TouchAction::Enum type; + aap_protobuf::service::input::message::TouchAction type; uint32_t x; uint32_t y; uint32_t pointerId; diff --git a/include/f1x/openauto/autoapp/Projection/SequentialBuffer.hpp b/include/f1x/openauto/autoapp/Projection/SequentialBuffer.hpp index 153b687..179aabe 100644 --- a/include/f1x/openauto/autoapp/Projection/SequentialBuffer.hpp +++ b/include/f1x/openauto/autoapp/Projection/SequentialBuffer.hpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include namespace f1x { diff --git a/include/f1x/openauto/autoapp/Projection/VideoOutput.hpp b/include/f1x/openauto/autoapp/Projection/VideoOutput.hpp index 3c67cf6..098fae3 100644 --- a/include/f1x/openauto/autoapp/Projection/VideoOutput.hpp +++ b/include/f1x/openauto/autoapp/Projection/VideoOutput.hpp @@ -35,8 +35,8 @@ class VideoOutput: public IVideoOutput public: VideoOutput(configuration::IConfiguration::Pointer configuration); - aasdk::proto::enums::VideoFPS::Enum getVideoFPS() const override; - aasdk::proto::enums::VideoResolution::Enum getVideoResolution() const override; + aap_protobuf::service::media::shared::message::VideoFrameRateType getVideoFPS() const override; + aap_protobuf::service::media::shared::message::VideoCodecResolutionType getVideoResolution() const override; size_t getScreenDPI() const override; QRect getVideoMargins() const override; diff --git a/include/f1x/openauto/autoapp/Service/AndroidAutoEntity.hpp b/include/f1x/openauto/autoapp/Service/AndroidAutoEntity.hpp index 0ae914c..a30381f 100644 --- a/include/f1x/openauto/autoapp/Service/AndroidAutoEntity.hpp +++ b/include/f1x/openauto/autoapp/Service/AndroidAutoEntity.hpp @@ -19,10 +19,10 @@ #pragma once #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include @@ -53,14 +53,17 @@ public: void stop() override; void pause() override; void resume() override; - void onVersionResponse(uint16_t majorCode, uint16_t minorCode, aasdk::proto::enums::VersionResponseStatus::Enum status) override; + // TODO: on channel open request... on channel close... on navigation focus, on voice session notification, on user switch, on call availability, on service disc update, on battery status, on car connected devices + void onVersionResponse(uint16_t majorCode, uint16_t minorCode, aap_protobuf::shared::MessageStatus status) override; void onHandshake(const aasdk::common::DataConstBuffer& payload) override; - void onServiceDiscoveryRequest(const aasdk::proto::messages::ServiceDiscoveryRequest& request) override; - void onAudioFocusRequest(const aasdk::proto::messages::AudioFocusRequest& request) override; - void onShutdownRequest(const aasdk::proto::messages::ShutdownRequest& request) override; - void onShutdownResponse(const aasdk::proto::messages::ShutdownResponse& response) override; - void onNavigationFocusRequest(const aasdk::proto::messages::NavigationFocusRequest& request) override; - void onPingResponse(const aasdk::proto::messages::PingResponse& response) override; + void onServiceDiscoveryRequest(const aap_protobuf::channel::control::servicediscovery::event::ServiceDiscoveryRequest& request) override; + void onAudioFocusRequest(const aap_protobuf::channel::control::focus::audio::event::AudioFocusRequest& request) override; + void onByeByeRequest(const aap_protobuf::channel::control::byebye::event::ByeByeRequest& request) override; + void onByeByeResponse(const aap_protobuf::channel::control::byebye::notification::ByeByeResponse& response) override; + void onNavigationFocusRequest(const aap_protobuf::channel::control::focus::navigation::event::NavFocusRequestNotification& request) 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; private: diff --git a/include/f1x/openauto/autoapp/Service/AndroidAutoEntityFactory.hpp b/include/f1x/openauto/autoapp/Service/AndroidAutoEntityFactory.hpp index b9fed4f..9c45e27 100644 --- a/include/f1x/openauto/autoapp/Service/AndroidAutoEntityFactory.hpp +++ b/include/f1x/openauto/autoapp/Service/AndroidAutoEntityFactory.hpp @@ -19,7 +19,7 @@ #pragma once #include -#include +#include #include #include #include diff --git a/include/f1x/openauto/autoapp/Service/AudioInputService.hpp b/include/f1x/openauto/autoapp/Service/AudioInputService.hpp deleted file mode 100644 index c8e56c2..0000000 --- a/include/f1x/openauto/autoapp/Service/AudioInputService.hpp +++ /dev/null @@ -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 . -*/ - -#pragma once - -#include -#include -#include - -namespace f1x -{ -namespace openauto -{ -namespace autoapp -{ -namespace service -{ - -class AudioInputService: public aasdk::channel::av::IAVInputServiceChannelEventHandler, public IService, public std::enable_shared_from_this -{ -public: - typedef std::shared_ptr 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::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_; -}; - -} -} -} -} diff --git a/include/f1x/openauto/autoapp/Service/AudioService.hpp b/include/f1x/openauto/autoapp/Service/AudioService.hpp deleted file mode 100644 index 034ddec..0000000 --- a/include/f1x/openauto/autoapp/Service/AudioService.hpp +++ /dev/null @@ -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 . -*/ - -#pragma once - -#include -#include -#include -#include - -namespace f1x -{ -namespace openauto -{ -namespace autoapp -{ -namespace service -{ - -class AudioService: public aasdk::channel::av::IAudioServiceChannelEventHandler, public IService, public std::enable_shared_from_this -{ -public: - typedef std::shared_ptr 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::shared_from_this; - - boost::asio::io_service::strand strand_; - aasdk::channel::av::IAudioServiceChannel::Pointer channel_; - projection::IAudioOutput::Pointer audioOutput_; - int32_t session_; -}; - -} -} -} -} diff --git a/include/f1x/openauto/autoapp/Service/Bluetooth/BluetoothService.hpp b/include/f1x/openauto/autoapp/Service/Bluetooth/BluetoothService.hpp new file mode 100644 index 0000000..b6bd3fa --- /dev/null +++ b/include/f1x/openauto/autoapp/Service/Bluetooth/BluetoothService.hpp @@ -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 . +*/ + +#pragma once + +#include +#include +#include + +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 { + 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::shared_from_this; + + boost::asio::io_service::strand strand_; + aasdk::channel::bluetooth::BluetoothService::Pointer channel_; + projection::IBluetoothDevice::Pointer bluetoothDevice_; + }; + + } + } + } + } +} \ No newline at end of file diff --git a/include/f1x/openauto/autoapp/Service/BluetoothService.hpp b/include/f1x/openauto/autoapp/Service/BluetoothService.hpp deleted file mode 100644 index 27b46d8..0000000 --- a/include/f1x/openauto/autoapp/Service/BluetoothService.hpp +++ /dev/null @@ -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 . -*/ - -#pragma once - -#include -#include -#include - -namespace f1x -{ -namespace openauto -{ -namespace autoapp -{ -namespace service -{ - -class BluetoothService: public aasdk::channel::bluetooth::IBluetoothServiceChannelEventHandler, public IService, public std::enable_shared_from_this -{ -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::shared_from_this; - - boost::asio::io_service::strand strand_; - aasdk::channel::bluetooth::BluetoothServiceChannel::Pointer channel_; - projection::IBluetoothDevice::Pointer bluetoothDevice_; -}; - -} -} -} -} diff --git a/include/f1x/openauto/autoapp/Service/GenericNotification/GenericNotificationService.hpp b/include/f1x/openauto/autoapp/Service/GenericNotification/GenericNotificationService.hpp new file mode 100644 index 0000000..b4a9da5 --- /dev/null +++ b/include/f1x/openauto/autoapp/Service/GenericNotification/GenericNotificationService.hpp @@ -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 . +*/ + +#pragma once + +#include +#include +#include +#include + +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 { + 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::shared_from_this; + boost::asio::deadline_timer timer_; + boost::asio::io_service::strand strand_; + aasdk::channel::genericnotification::GenericNotificationService::Pointer channel_; + }; + + } + } + } + } +} \ No newline at end of file diff --git a/include/f1x/openauto/autoapp/Service/IAndroidAutoEntityEventHandler.hpp b/include/f1x/openauto/autoapp/Service/IAndroidAutoEntityEventHandler.hpp index 648d125..2ae816d 100644 --- a/include/f1x/openauto/autoapp/Service/IAndroidAutoEntityEventHandler.hpp +++ b/include/f1x/openauto/autoapp/Service/IAndroidAutoEntityEventHandler.hpp @@ -18,7 +18,7 @@ #pragma once -#include +#include namespace f1x { diff --git a/include/f1x/openauto/autoapp/Service/IAndroidAutoEntityFactory.hpp b/include/f1x/openauto/autoapp/Service/IAndroidAutoEntityFactory.hpp index 97b958b..5a174fd 100644 --- a/include/f1x/openauto/autoapp/Service/IAndroidAutoEntityFactory.hpp +++ b/include/f1x/openauto/autoapp/Service/IAndroidAutoEntityFactory.hpp @@ -18,8 +18,8 @@ #pragma once -#include -#include +#include +#include #include namespace f1x diff --git a/include/f1x/openauto/autoapp/Service/IPinger.hpp b/include/f1x/openauto/autoapp/Service/IPinger.hpp index d345ed3..c283c88 100644 --- a/include/f1x/openauto/autoapp/Service/IPinger.hpp +++ b/include/f1x/openauto/autoapp/Service/IPinger.hpp @@ -18,7 +18,7 @@ #pragma once -#include +#include namespace f1x { diff --git a/include/f1x/openauto/autoapp/Service/IService.hpp b/include/f1x/openauto/autoapp/Service/IService.hpp index 7c66f49..5a8a91a 100644 --- a/include/f1x/openauto/autoapp/Service/IService.hpp +++ b/include/f1x/openauto/autoapp/Service/IService.hpp @@ -20,7 +20,9 @@ #include #include -#include +#include +#include +#include namespace f1x { @@ -42,7 +44,7 @@ public: virtual void stop() = 0; virtual void pause() = 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 ServiceList; diff --git a/include/f1x/openauto/autoapp/Service/IServiceFactory.hpp b/include/f1x/openauto/autoapp/Service/IServiceFactory.hpp index 6049d9d..e7d724a 100644 --- a/include/f1x/openauto/autoapp/Service/IServiceFactory.hpp +++ b/include/f1x/openauto/autoapp/Service/IServiceFactory.hpp @@ -18,7 +18,7 @@ #pragma once -#include +#include #include namespace f1x diff --git a/include/f1x/openauto/autoapp/Service/InputService.hpp b/include/f1x/openauto/autoapp/Service/InputService.hpp deleted file mode 100644 index 03ed01b..0000000 --- a/include/f1x/openauto/autoapp/Service/InputService.hpp +++ /dev/null @@ -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 . -*/ - -#pragma once - -#include -#include -#include -#include -#include - -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 -{ -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::shared_from_this; - - boost::asio::io_service::strand strand_; - aasdk::channel::input::InputServiceChannel::Pointer channel_; - projection::IInputDevice::Pointer inputDevice_; -}; - -} -} -} -} diff --git a/include/f1x/openauto/autoapp/Service/InputSource/InputSourceService.hpp b/include/f1x/openauto/autoapp/Service/InputSource/InputSourceService.hpp new file mode 100644 index 0000000..adc5816 --- /dev/null +++ b/include/f1x/openauto/autoapp/Service/InputSource/InputSourceService.hpp @@ -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 . +*/ + +#pragma once + +#include +#include +#include +#include +#include + +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 { + 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::shared_from_this; + + boost::asio::io_service::strand strand_; + aasdk::channel::inputsource::InputSourceService::Pointer channel_; + projection::IInputDevice::Pointer inputDevice_; + }; + + } + } + } + } +} \ No newline at end of file diff --git a/include/f1x/openauto/autoapp/Service/MediaBrowser/MediaBrowserService.hpp b/include/f1x/openauto/autoapp/Service/MediaBrowser/MediaBrowserService.hpp new file mode 100644 index 0000000..e2455b9 --- /dev/null +++ b/include/f1x/openauto/autoapp/Service/MediaBrowser/MediaBrowserService.hpp @@ -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 . +*/ + +#pragma once + +#include +#include +#include +#include + +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 { + 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::shared_from_this; + boost::asio::deadline_timer timer_; + boost::asio::io_service::strand strand_; + aasdk::channel::mediabrowser::MediaBrowserService::Pointer channel_; + }; + + } + } + } + } +} \ No newline at end of file diff --git a/include/f1x/openauto/autoapp/Service/MediaPlaybackStatus/MediaPlaybackStatusService.hpp b/include/f1x/openauto/autoapp/Service/MediaPlaybackStatus/MediaPlaybackStatusService.hpp new file mode 100644 index 0000000..c4d543b --- /dev/null +++ b/include/f1x/openauto/autoapp/Service/MediaPlaybackStatus/MediaPlaybackStatusService.hpp @@ -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 . +*/ + +#pragma once + +#include +#include +#include +#include + +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 { + 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::shared_from_this; + boost::asio::deadline_timer timer_; + boost::asio::io_service::strand strand_; + aasdk::channel::mediaplaybackstatus::MediaPlaybackStatusService::Pointer channel_; + }; + + } + } + } + } +} \ No newline at end of file diff --git a/include/f1x/openauto/autoapp/Service/MediaSink/AudioMediaSinkService.hpp b/include/f1x/openauto/autoapp/Service/MediaSink/AudioMediaSinkService.hpp new file mode 100644 index 0000000..b46f1ea --- /dev/null +++ b/include/f1x/openauto/autoapp/Service/MediaSink/AudioMediaSinkService.hpp @@ -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 . +*/ + +#pragma once +#include +#include +#include +#include +#include + +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 { + public: + typedef std::shared_ptr 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::shared_from_this; + boost::asio::io_service::strand strand_; + aasdk::channel::mediasink::audio::IAudioMediaSinkService::Pointer channel_; + projection::IAudioOutput::Pointer audioOutput_; + int32_t session_; + }; + } + } + } + } +} \ No newline at end of file diff --git a/include/f1x/openauto/autoapp/Service/SystemAudioService.hpp b/include/f1x/openauto/autoapp/Service/MediaSink/GuidanceAudioService.hpp similarity index 54% rename from include/f1x/openauto/autoapp/Service/SystemAudioService.hpp rename to include/f1x/openauto/autoapp/Service/MediaSink/GuidanceAudioService.hpp index af775b2..62d3bcc 100644 --- a/include/f1x/openauto/autoapp/Service/SystemAudioService.hpp +++ b/include/f1x/openauto/autoapp/Service/MediaSink/GuidanceAudioService.hpp @@ -18,25 +18,24 @@ #pragma once -#include -#include +#include +#include -namespace f1x -{ -namespace openauto -{ -namespace autoapp -{ -namespace service -{ +namespace f1x { + namespace openauto { + namespace autoapp { + namespace service { + namespace mediasink { + class GuidanceAudioService : public AudioMediaSinkService { + public: + GuidanceAudioService(boost::asio::io_service &ioService, + aasdk::messenger::IMessenger::Pointer messenger, + projection::IAudioOutput::Pointer audioOutput); -class SystemAudioService: public AudioService -{ -public: - SystemAudioService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IAudioOutput::Pointer audioOutput); -}; + }; -} -} -} -} + } + } + } + } +} \ No newline at end of file diff --git a/include/f1x/openauto/autoapp/Service/MediaAudioService.hpp b/include/f1x/openauto/autoapp/Service/MediaSink/MediaAudioService.hpp similarity index 54% rename from include/f1x/openauto/autoapp/Service/MediaAudioService.hpp rename to include/f1x/openauto/autoapp/Service/MediaSink/MediaAudioService.hpp index bbd1414..d279405 100644 --- a/include/f1x/openauto/autoapp/Service/MediaAudioService.hpp +++ b/include/f1x/openauto/autoapp/Service/MediaSink/MediaAudioService.hpp @@ -18,25 +18,24 @@ #pragma once -#include -#include +#include +#include -namespace f1x -{ -namespace openauto -{ -namespace autoapp -{ -namespace service -{ -class MediaAudioService: public AudioService -{ -public: - MediaAudioService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IAudioOutput::Pointer audioOutput); -}; +namespace f1x { + namespace openauto { + namespace autoapp { + namespace service { + namespace mediasink { + class MediaAudioService : public AudioMediaSinkService { + public: + MediaAudioService(boost::asio::io_service &ioService, + aasdk::messenger::IMessenger::Pointer messenger, + projection::IAudioOutput::Pointer audioOutput); + }; -} -} -} -} + } + } + } + } +} \ No newline at end of file diff --git a/src/autoapp/Service/MediaAudioService.cpp b/include/f1x/openauto/autoapp/Service/MediaSink/SystemAudioService.hpp similarity index 50% rename from src/autoapp/Service/MediaAudioService.cpp rename to include/f1x/openauto/autoapp/Service/MediaSink/SystemAudioService.hpp index b754d21..82ee072 100644 --- a/src/autoapp/Service/MediaAudioService.cpp +++ b/include/f1x/openauto/autoapp/Service/MediaSink/SystemAudioService.hpp @@ -16,25 +16,28 @@ * along with openauto. If not, see . */ -#include -#include +#pragma once -namespace f1x -{ -namespace openauto -{ -namespace autoapp -{ -namespace service -{ +#include +#include -MediaAudioService::MediaAudioService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IAudioOutput::Pointer audioOutput) - : AudioService(ioService, std::make_shared(strand_, std::move(messenger)), std::move(audioOutput)) -{ +namespace f1x { + namespace openauto { + namespace autoapp { + namespace service { + namespace mediasink { + class SystemAudioService : public AudioMediaSinkService { + public: + SystemAudioService(boost::asio::io_service &ioService, + aasdk::messenger::IMessenger::Pointer messenger, + projection::IAudioOutput::Pointer audioOutput); -} + protected: + projection::IAudioOutput::Pointer audioOutput_; + }; -} -} -} -} + } + } + } + } +} \ No newline at end of file diff --git a/include/f1x/openauto/autoapp/Service/MediaSink/TelephonyAudioService.hpp b/include/f1x/openauto/autoapp/Service/MediaSink/TelephonyAudioService.hpp new file mode 100644 index 0000000..d3dcacd --- /dev/null +++ b/include/f1x/openauto/autoapp/Service/MediaSink/TelephonyAudioService.hpp @@ -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 . +*/ + +#pragma once + +#include +#include + + +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_; + }; + + } + } + } + } +} \ No newline at end of file diff --git a/include/f1x/openauto/autoapp/Service/MediaSink/VideoMediaSinkService.hpp b/include/f1x/openauto/autoapp/Service/MediaSink/VideoMediaSinkService.hpp new file mode 100644 index 0000000..11a05e0 --- /dev/null +++ b/include/f1x/openauto/autoapp/Service/MediaSink/VideoMediaSinkService.hpp @@ -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 . +*/ + +#pragma once + +#include +#include +#include +#include +#include + +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 { + public: + typedef std::shared_ptr 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::shared_from_this; + boost::asio::io_service::strand strand_; + aasdk::channel::mediasink::video::IVideoMediaSinkService::Pointer channel_; + projection::IVideoOutput::Pointer videoOutput_; + int32_t session_; + }; + } + } + } + } +} \ No newline at end of file diff --git a/include/f1x/openauto/autoapp/Service/SpeechAudioService.hpp b/include/f1x/openauto/autoapp/Service/MediaSink/VideoService.hpp similarity index 52% rename from include/f1x/openauto/autoapp/Service/SpeechAudioService.hpp rename to include/f1x/openauto/autoapp/Service/MediaSink/VideoService.hpp index d71f1a9..29a56e3 100644 --- a/include/f1x/openauto/autoapp/Service/SpeechAudioService.hpp +++ b/include/f1x/openauto/autoapp/Service/MediaSink/VideoService.hpp @@ -18,25 +18,27 @@ #pragma once -#include -#include +#include +#include -namespace f1x -{ -namespace openauto -{ -namespace autoapp -{ -namespace service -{ -class SpeechAudioService: public AudioService -{ -public: - SpeechAudioService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IAudioOutput::Pointer audioOutput); -}; +namespace f1x { + namespace openauto { + namespace autoapp { + namespace service { + namespace mediasink { + class VideoService : public VideoMediaSinkService { + public: + VideoService(boost::asio::io_service &ioService, + aasdk::messenger::IMessenger::Pointer messenger, + projection::IVideoOutput::Pointer videoOutput); -} -} -} -} + protected: + projection::IVideoOutput::Pointer videoOutput; + }; + + } + } + } + } +} \ No newline at end of file diff --git a/include/f1x/openauto/autoapp/Service/MediaSource/MediaSourceService.hpp b/include/f1x/openauto/autoapp/Service/MediaSource/MediaSourceService.hpp new file mode 100644 index 0000000..214ecd8 --- /dev/null +++ b/include/f1x/openauto/autoapp/Service/MediaSource/MediaSourceService.hpp @@ -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 . +*/ + +#pragma once + +#include +#include +#include +#include +#include + +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 { + public: + typedef std::shared_ptr 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::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_; + }; + } +} +} +} +} diff --git a/include/f1x/openauto/autoapp/Service/MediaSource/MicrophoneMediaSourceService.hpp b/include/f1x/openauto/autoapp/Service/MediaSource/MicrophoneMediaSourceService.hpp new file mode 100644 index 0000000..6e11a46 --- /dev/null +++ b/include/f1x/openauto/autoapp/Service/MediaSource/MicrophoneMediaSourceService.hpp @@ -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 . +*/ + +#pragma once + +#include +#include + + +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_; + }; + + } + } + } + } +} \ No newline at end of file diff --git a/include/f1x/openauto/autoapp/Service/NavigationStatus/NavigationStatusService.hpp b/include/f1x/openauto/autoapp/Service/NavigationStatus/NavigationStatusService.hpp new file mode 100644 index 0000000..8c026e5 --- /dev/null +++ b/include/f1x/openauto/autoapp/Service/NavigationStatus/NavigationStatusService.hpp @@ -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 . +*/ + +#pragma once + +#include +#include +#include +#include + +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 { + 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::shared_from_this; + boost::asio::deadline_timer timer_; + boost::asio::io_service::strand strand_; + aasdk::channel::navigationstatus::NavigationStatusService::Pointer channel_; + }; + + } + } + } + } +} \ No newline at end of file diff --git a/include/f1x/openauto/autoapp/Service/PhoneStatus/PhoneStatusService.hpp b/include/f1x/openauto/autoapp/Service/PhoneStatus/PhoneStatusService.hpp new file mode 100644 index 0000000..a5b5f2e --- /dev/null +++ b/include/f1x/openauto/autoapp/Service/PhoneStatus/PhoneStatusService.hpp @@ -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 . +*/ + +#pragma once + +#include +#include +#include +#include + +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 { + 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::shared_from_this; + boost::asio::deadline_timer timer_; + boost::asio::io_service::strand strand_; + aasdk::channel::phonestatus::PhoneStatusService::Pointer channel_; + }; + + } + } + } + } +} \ No newline at end of file diff --git a/include/f1x/openauto/autoapp/Service/Radio/RadioService.hpp b/include/f1x/openauto/autoapp/Service/Radio/RadioService.hpp new file mode 100644 index 0000000..305b591 --- /dev/null +++ b/include/f1x/openauto/autoapp/Service/Radio/RadioService.hpp @@ -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 . +*/ + +#pragma once + +#include +#include +#include +#include + +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 { + 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::shared_from_this; + boost::asio::deadline_timer timer_; + boost::asio::io_service::strand strand_; + aasdk::channel::radio::RadioService::Pointer channel_; + }; + + } + } + } + } +} \ No newline at end of file diff --git a/include/f1x/openauto/autoapp/Service/Sensor/SensorService.hpp b/include/f1x/openauto/autoapp/Service/Sensor/SensorService.hpp new file mode 100644 index 0000000..c57c557 --- /dev/null +++ b/include/f1x/openauto/autoapp/Service/Sensor/SensorService.hpp @@ -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 . +*/ + +#pragma once + +#include +#include +#include +#include +#include + +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 { + 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::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; + }; + + } + } + } + } +} \ No newline at end of file diff --git a/include/f1x/openauto/autoapp/Service/SensorService.hpp b/include/f1x/openauto/autoapp/Service/SensorService.hpp deleted file mode 100644 index 93d96d6..0000000 --- a/include/f1x/openauto/autoapp/Service/SensorService.hpp +++ /dev/null @@ -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 . -*/ - -#pragma once - -#include -#include -#include - -namespace f1x -{ -namespace openauto -{ -namespace autoapp -{ -namespace service -{ - -class SensorService: public aasdk::channel::sensor::ISensorServiceChannelEventHandler, public IService, public std::enable_shared_from_this -{ -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::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; -}; - -} -} -} -} diff --git a/include/f1x/openauto/autoapp/Service/WifiService.hpp b/include/f1x/openauto/autoapp/Service/Service.hpp similarity index 50% rename from include/f1x/openauto/autoapp/Service/WifiService.hpp rename to include/f1x/openauto/autoapp/Service/Service.hpp index f9aefcf..e406e48 100644 --- a/include/f1x/openauto/autoapp/Service/WifiService.hpp +++ b/include/f1x/openauto/autoapp/Service/Service.hpp @@ -18,39 +18,37 @@ #pragma once -#include +#include +#include #include -#include -#include -namespace f1x -{ -namespace openauto -{ -namespace autoapp -{ -namespace service -{ +namespace f1x { + namespace openauto { + namespace autoapp { + namespace service { -class WifiService: public IService, public std::enable_shared_from_this -{ -public: - typedef std::shared_ptr Pointer; + class Service + : public IService { + public: + Service(boost::asio::io_service &ioService); - WifiService(configuration::IConfiguration::Pointer configuration); + void start() override; - void start() override; - void stop() override; - void pause() override; - void resume() override; - void fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response) override; + void stop() override; -private: - using std::enable_shared_from_this::shared_from_this; - configuration::IConfiguration::Pointer configuration_; -}; + void pause() override; -} -} -} -} + void resume() override; + + void fillFeatures(aap_protobuf::channel::control::servicediscovery::notification::ServiceDiscoveryResponse &response) override; + + private: + + boost::asio::io_service::strand strand_; + + }; + } + } + } + } +} \ No newline at end of file diff --git a/include/f1x/openauto/autoapp/Service/ServiceFactory.hpp b/include/f1x/openauto/autoapp/Service/ServiceFactory.hpp index 2ee9c6b..7cf8500 100644 --- a/include/f1x/openauto/autoapp/Service/ServiceFactory.hpp +++ b/include/f1x/openauto/autoapp/Service/ServiceFactory.hpp @@ -21,32 +21,38 @@ #include #include -namespace f1x -{ -namespace openauto -{ -namespace autoapp -{ -namespace service -{ +namespace f1x { + namespace openauto { + namespace autoapp { + namespace service { -class ServiceFactory: public IServiceFactory -{ -public: - ServiceFactory(boost::asio::io_service& ioService, configuration::IConfiguration::Pointer configuration); - ServiceList create(aasdk::messenger::IMessenger::Pointer messenger) override; + class ServiceFactory : public IServiceFactory { + public: + ServiceFactory(boost::asio::io_service &ioService, configuration::IConfiguration::Pointer configuration); + ServiceList create(aasdk::messenger::IMessenger::Pointer messenger) override; -private: - IService::Pointer createVideoService(aasdk::messenger::IMessenger::Pointer messenger); - IService::Pointer createBluetoothService(aasdk::messenger::IMessenger::Pointer messenger); - IService::Pointer createInputService(aasdk::messenger::IMessenger::Pointer messenger); - void createAudioServices(ServiceList& serviceList, aasdk::messenger::IMessenger::Pointer messenger); + private: + IService::Pointer createBluetoothService(aasdk::messenger::IMessenger::Pointer messenger); + IService::Pointer createGenericNotificationService(aasdk::messenger::IMessenger::Pointer messenger); + IService::Pointer createInputService(aasdk::messenger::IMessenger::Pointer messenger); + IService::Pointer createMediaBrowserService(aasdk::messenger::IMessenger::Pointer messenger); + IService::Pointer createMediaPlaybackStatusService(aasdk::messenger::IMessenger::Pointer messenger); - boost::asio::io_service& ioService_; - configuration::IConfiguration::Pointer configuration_; -}; + void createMediaSinkServices(ServiceList &serviceList, aasdk::messenger::IMessenger::Pointer messenger); + void createMediaSourceServices(ServiceList &serviceList, aasdk::messenger::IMessenger::Pointer messenger); -} -} -} + IService::Pointer createNavigationStatusService(aasdk::messenger::IMessenger::Pointer messenger); + IService::Pointer createPhoneStatusService(aasdk::messenger::IMessenger::Pointer messenger); + IService::Pointer createRadioService(aasdk::messenger::IMessenger::Pointer messenger); + IService::Pointer createSensorService(aasdk::messenger::IMessenger::Pointer messenger); + IService::Pointer createVendorExtensionService(aasdk::messenger::IMessenger::Pointer messenger); + IService::Pointer createWifiProjectionService(aasdk::messenger::IMessenger::Pointer messenger); + + boost::asio::io_service &ioService_; + configuration::IConfiguration::Pointer configuration_; + }; + + } + } + } } diff --git a/include/f1x/openauto/autoapp/Service/VendorExtension/VendorExtensionService.hpp b/include/f1x/openauto/autoapp/Service/VendorExtension/VendorExtensionService.hpp new file mode 100644 index 0000000..dea205b --- /dev/null +++ b/include/f1x/openauto/autoapp/Service/VendorExtension/VendorExtensionService.hpp @@ -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 . +*/ + +#pragma once + +#include +#include +#include +#include + +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 { + 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::shared_from_this; + boost::asio::deadline_timer timer_; + boost::asio::io_service::strand strand_; + aasdk::channel::vendorextension::VendorExtensionService::Pointer channel_; + }; + + } + } + } + } +} \ No newline at end of file diff --git a/include/f1x/openauto/autoapp/Service/VideoService.hpp b/include/f1x/openauto/autoapp/Service/VideoService.hpp deleted file mode 100644 index 391e1bc..0000000 --- a/include/f1x/openauto/autoapp/Service/VideoService.hpp +++ /dev/null @@ -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 . -*/ - -#pragma once - -#include -#include -#include -#include -#include - -namespace f1x -{ -namespace openauto -{ -namespace autoapp -{ -namespace service -{ - -class VideoService: public aasdk::channel::av::IVideoServiceChannelEventHandler, public IService, public std::enable_shared_from_this -{ -public: - typedef std::shared_ptr 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::shared_from_this; - void sendVideoFocusIndication(); - - boost::asio::io_service::strand strand_; - aasdk::channel::av::VideoServiceChannel::Pointer channel_; - projection::IVideoOutput::Pointer videoOutput_; - int32_t session_; -}; - -} -} -} -} diff --git a/include/f1x/openauto/autoapp/Service/WifiProjection/WifiProjectionService.hpp b/include/f1x/openauto/autoapp/Service/WifiProjection/WifiProjectionService.hpp new file mode 100644 index 0000000..f4450ee --- /dev/null +++ b/include/f1x/openauto/autoapp/Service/WifiProjection/WifiProjectionService.hpp @@ -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 . +*/ + +#pragma once + +#include +#include +#include +#include + +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 { + 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::shared_from_this; + boost::asio::deadline_timer timer_; + boost::asio::io_service::strand strand_; + aasdk::channel::wifiprojection::WifiProjectionService::Pointer channel_; + }; + + } + } + } + } +} \ No newline at end of file diff --git a/include/f1x/openauto/autoapp/UI/ConnectDialog.hpp b/include/f1x/openauto/autoapp/UI/ConnectDialog.hpp index f97d5fa..5d39d7a 100644 --- a/include/f1x/openauto/autoapp/UI/ConnectDialog.hpp +++ b/include/f1x/openauto/autoapp/UI/ConnectDialog.hpp @@ -3,8 +3,8 @@ #include #include #include -#include -#include +#include +#include #include namespace Ui { diff --git a/include/f1x/openauto/autoapp/UI/SettingsWindow.hpp b/include/f1x/openauto/autoapp/UI/SettingsWindow.hpp index e1faab3..367dd32 100644 --- a/include/f1x/openauto/autoapp/UI/SettingsWindow.hpp +++ b/include/f1x/openauto/autoapp/UI/SettingsWindow.hpp @@ -23,7 +23,6 @@ #include #include #include -#include class QCheckBox; class QTimer; @@ -100,7 +99,7 @@ private: void load(); void loadButtonCheckBoxes(); void saveButtonCheckBoxes(); - void saveButtonCheckBox(const QCheckBox* checkBox, configuration::IConfiguration::ButtonCodes& buttonCodes, aasdk::proto::enums::ButtonCode::Enum buttonCode); + void saveButtonCheckBox(const QCheckBox* checkBox, configuration::IConfiguration::ButtonCodes& buttonCodes, aap_protobuf::service::media::sink::KeyCode buttonCode); void setButtonCheckBoxes(bool value); Ui::SettingsWindow* ui_; diff --git a/include/f1x/openauto/btservice/AndroidBluetoothServer.hpp b/include/f1x/openauto/btservice/AndroidBluetoothServer.hpp index bfa40d6..4eb540b 100644 --- a/include/f1x/openauto/btservice/AndroidBluetoothServer.hpp +++ b/include/f1x/openauto/btservice/AndroidBluetoothServer.hpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include namespace f1x { diff --git a/src/autoapp/App.cpp b/src/autoapp/App.cpp index 3967385..b016ea2 100644 --- a/src/autoapp/App.cpp +++ b/src/autoapp/App.cpp @@ -17,8 +17,8 @@ */ #include -#include -#include +#include +#include #include #include diff --git a/src/autoapp/Configuration/Configuration.cpp b/src/autoapp/Configuration/Configuration.cpp index a39bb1f..63e7908 100644 --- a/src/autoapp/Configuration/Configuration.cpp +++ b/src/autoapp/Configuration/Configuration.cpp @@ -60,8 +60,11 @@ const std::string Configuration::cVideoOMXLayerIndexKey = "Video.OMXLayerIndex"; const std::string Configuration::cVideoMarginWidth = "Video.MarginWidth"; const std::string Configuration::cVideoMarginHeight = "Video.MarginHeight"; -const std::string Configuration::cAudioMusicAudioChannelEnabled = "Audio.MusicAudioChannelEnabled"; -const std::string Configuration::cAudioSpeechAudioChannelEnabled = "Audio.SpeechAudioChannelEnabled"; +const std::string Configuration::Audio::Channel::cMediaEnabled = "Audio.Channel.MediaEnabled"; +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::cBluetoothAdapterTypeKey = "Bluetooth.AdapterType"; @@ -120,11 +123,11 @@ void Configuration::load() showAutoPlay_ = iniConfig.get(cGeneralShowAutoPlayKey, false); instantPlay_ = iniConfig.get(cGeneralInstantPlayKey, false); - videoFPS_ = static_cast(iniConfig.get(cVideoFPSKey, - aasdk::proto::enums::VideoFPS::_30)); + videoFPS_ = static_cast(iniConfig.get(cVideoFPSKey, + aap_protobuf::service::media::shared::message::VideoFrameRateType::VIDEO_FPS_30)); - videoResolution_ = static_cast(iniConfig.get(cVideoResolutionKey, - aasdk::proto::enums::VideoResolution::_480p)); + videoResolution_ = static_cast(iniConfig.get(cVideoResolutionKey, + aap_protobuf::service::media::shared::message::VideoCodecResolutionType::VIDEO_800x480)); screenDPI_ = iniConfig.get(cVideoScreenDPIKey, 140); omxLayerIndex_ = iniConfig.get(cVideoOMXLayerIndexKey, 1); @@ -138,8 +141,12 @@ void Configuration::load() static_cast(BluetoothAdapterType::NONE))); bluetoothRemoteAdapterAddress_ = iniConfig.get(cBluetoothRemoteAdapterAddressKey, ""); - musicAudioChannelEnabled_ = iniConfig.get(cAudioMusicAudioChannelEnabled, true); - speechAudiochannelEnabled_ = iniConfig.get(cAudioSpeechAudioChannelEnabled, true); + + _audioChannelEnabledMedia = iniConfig.get(Audio::Channel::cMediaEnabled, true); + _audioChannelEnabledGuidance = iniConfig.get(Audio::Channel::cGuidanceEnabled, true); + _audioChannelEnabledSystem = iniConfig.get(Audio::Channel::cSystemEnabled, true); + _audioChannelEnabledTelephony = iniConfig.get(Audio::Channel::cTelephonyEnabled, true); + audioOutputBackendType_ = static_cast(iniConfig.get(cAudioOutputBackendType, static_cast(AudioOutputBackendType::RTAUDIO))); } catch(const boost::property_tree::ini_parser_error& e) @@ -171,8 +178,8 @@ void Configuration::reset() mp3AutoPlay_ = false; showAutoPlay_ = false; instantPlay_ = false; - videoFPS_ = aasdk::proto::enums::VideoFPS::_30; - videoResolution_ = aasdk::proto::enums::VideoResolution::_480p; + videoFPS_ = aap_protobuf::service::media::shared::message::VideoFrameRateType::VIDEO_FPS_30; + videoResolution_ = aap_protobuf::service::media::shared::message::VideoCodecResolutionType::VIDEO_800x480; screenDPI_ = 140; omxLayerIndex_ = 1; videoMargins_ = QRect(0, 0, 0, 0); @@ -181,8 +188,12 @@ void Configuration::reset() buttonCodes_.clear(); bluetoothAdapterType_ = BluetoothAdapterType::NONE; bluetoothRemoteAdapterAddress_ = ""; - musicAudioChannelEnabled_ = true; - speechAudiochannelEnabled_ = true; + + _audioChannelEnabledMedia = true; + _audioChannelEnabledGuidance = true; + _audioChannelEnabledSystem = true; + _audioChannelEnabledTelephony = true; + audioOutputBackendType_ = AudioOutputBackendType::QT; } @@ -223,9 +234,12 @@ void Configuration::save() iniConfig.put(cBluetoothAdapterTypeKey, static_cast(bluetoothAdapterType_)); iniConfig.put(cBluetoothRemoteAdapterAddressKey, bluetoothRemoteAdapterAddress_); - iniConfig.put(cAudioMusicAudioChannelEnabled, musicAudioChannelEnabled_); - iniConfig.put(cAudioSpeechAudioChannelEnabled, speechAudiochannelEnabled_); - iniConfig.put(cAudioOutputBackendType, static_cast(audioOutputBackendType_)); + iniConfig.put(Audio::Channel::cMediaEnabled, _audioChannelEnabledMedia); + iniConfig.put(Audio::Channel::cGuidanceEnabled, _audioChannelEnabledGuidance); + iniConfig.put(Audio::Channel::cSystemEnabled, _audioChannelEnabledSystem); + iniConfig.put(Audio::Channel::cTelephonyEnabled, _audioChannelEnabledTelephony); + + iniConfig.put(cAudioOutputBackendType, static_cast(audioOutputBackendType_)); boost::property_tree::ini_parser::write_ini(cConfigFileName, iniConfig); } @@ -428,22 +442,22 @@ bool Configuration::instantPlay() const return instantPlay_; } -aasdk::proto::enums::VideoFPS::Enum Configuration::getVideoFPS() const +aap_protobuf::service::media::shared::message::VideoFrameRateType Configuration::getVideoFPS() const { return videoFPS_; } -void Configuration::setVideoFPS(aasdk::proto::enums::VideoFPS::Enum value) +void Configuration::setVideoFPS(aap_protobuf::service::media::shared::message::VideoFrameRateType value) { videoFPS_ = value; } -aasdk::proto::enums::VideoResolution::Enum Configuration::getVideoResolution() const +aap_protobuf::service::media::shared::message::VideoCodecResolutionType Configuration::getVideoResolution() const { return videoResolution_; } -void Configuration::setVideoResolution(aasdk::proto::enums::VideoResolution::Enum value) +void Configuration::setVideoResolution(aap_protobuf::service::media::shared::message::VideoCodecResolutionType value) { videoResolution_ = value; } @@ -530,24 +544,44 @@ void Configuration::setBluetoothRemoteAdapterAddress(const std::string& value) bool Configuration::musicAudioChannelEnabled() const { - return musicAudioChannelEnabled_; + return _audioChannelEnabledMedia; } void Configuration::setMusicAudioChannelEnabled(bool value) { - musicAudioChannelEnabled_ = value; + _audioChannelEnabledMedia = value; } -bool Configuration::speechAudioChannelEnabled() const +bool Configuration::guidanceAudioChannelEnabled() const { - return speechAudiochannelEnabled_; + return _audioChannelEnabledGuidance; } -void Configuration::setSpeechAudioChannelEnabled(bool value) +void Configuration::setGuidanceAudioChannelEnabled(bool value) { - speechAudiochannelEnabled_ = value; + _audioChannelEnabledGuidance = value; } + bool Configuration::systemAudioChannelEnabled() const + { + return _audioChannelEnabledSystem; + } + + void Configuration::setSystemAudioChannelEnabled(bool value) + { + _audioChannelEnabledSystem = value; + } + + bool Configuration::telephonyAudioChannelEnabled() const + { + return _audioChannelEnabledTelephony; + } + + void Configuration::setTelephonyAudioChannelEnabled(bool value) + { + _audioChannelEnabledTelephony = value; + } + AudioOutputBackendType Configuration::getAudioOutputBackendType() const { return audioOutputBackendType_; @@ -683,26 +717,26 @@ QString Configuration::readFileContent(QString fileName) const void Configuration::readButtonCodes(boost::property_tree::ptree& iniConfig) { - this->insertButtonCode(iniConfig, cInputPlayButtonKey, aasdk::proto::enums::ButtonCode::PLAY); - this->insertButtonCode(iniConfig, cInputPauseButtonKey, aasdk::proto::enums::ButtonCode::PAUSE); - this->insertButtonCode(iniConfig, cInputTogglePlayButtonKey, aasdk::proto::enums::ButtonCode::TOGGLE_PLAY); - this->insertButtonCode(iniConfig, cInputNextTrackButtonKey, aasdk::proto::enums::ButtonCode::NEXT); - this->insertButtonCode(iniConfig, cInputPreviousTrackButtonKey, aasdk::proto::enums::ButtonCode::PREV); - this->insertButtonCode(iniConfig, cInputHomeButtonKey, aasdk::proto::enums::ButtonCode::HOME); - this->insertButtonCode(iniConfig, cInputPhoneButtonKey, aasdk::proto::enums::ButtonCode::PHONE); - this->insertButtonCode(iniConfig, cInputCallEndButtonKey, aasdk::proto::enums::ButtonCode::CALL_END); - this->insertButtonCode(iniConfig, cInputVoiceCommandButtonKey, aasdk::proto::enums::ButtonCode::MICROPHONE_1); - this->insertButtonCode(iniConfig, cInputLeftButtonKey, aasdk::proto::enums::ButtonCode::LEFT); - this->insertButtonCode(iniConfig, cInputRightButtonKey, aasdk::proto::enums::ButtonCode::RIGHT); - this->insertButtonCode(iniConfig, cInputUpButtonKey, aasdk::proto::enums::ButtonCode::UP); - this->insertButtonCode(iniConfig, cInputDownButtonKey, aasdk::proto::enums::ButtonCode::DOWN); - this->insertButtonCode(iniConfig, cInputScrollWheelButtonKey, aasdk::proto::enums::ButtonCode::SCROLL_WHEEL); - this->insertButtonCode(iniConfig, cInputBackButtonKey, aasdk::proto::enums::ButtonCode::BACK); - this->insertButtonCode(iniConfig, cInputEnterButtonKey, aasdk::proto::enums::ButtonCode::ENTER); - this->insertButtonCode(iniConfig, cInputNavButtonKey, aasdk::proto::enums::ButtonCode::NAVIGATION); + this->insertButtonCode(iniConfig, cInputPlayButtonKey, aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_PLAY); + this->insertButtonCode(iniConfig, cInputPauseButtonKey, aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_PAUSE); + this->insertButtonCode(iniConfig, cInputTogglePlayButtonKey, aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_PLAY_PAUSE); + this->insertButtonCode(iniConfig, cInputNextTrackButtonKey, aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_NEXT); + this->insertButtonCode(iniConfig, cInputPreviousTrackButtonKey, aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_PREVIOUS); + this->insertButtonCode(iniConfig, cInputHomeButtonKey, aap_protobuf::service::media::sink::KeyCode::KEYCODE_HOME); + this->insertButtonCode(iniConfig, cInputPhoneButtonKey, aap_protobuf::service::media::sink::KeyCode::KEYCODE_CALL); + this->insertButtonCode(iniConfig, cInputCallEndButtonKey, aap_protobuf::service::media::sink::KeyCode::KEYCODE_ENDCALL); + this->insertButtonCode(iniConfig, cInputVoiceCommandButtonKey, aap_protobuf::service::media::sink::KeyCode::KEYCODE_SEARCH); + this->insertButtonCode(iniConfig, cInputLeftButtonKey, aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_LEFT); + this->insertButtonCode(iniConfig, cInputRightButtonKey, aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_RIGHT); + this->insertButtonCode(iniConfig, cInputUpButtonKey, aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_UP); + this->insertButtonCode(iniConfig, cInputDownButtonKey, aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_DOWN); + this->insertButtonCode(iniConfig, cInputScrollWheelButtonKey, aap_protobuf::service::media::sink::KeyCode::KEYCODE_ROTARY_CONTROLLER); + this->insertButtonCode(iniConfig, cInputBackButtonKey, aap_protobuf::service::media::sink::KeyCode::KEYCODE_BACK); + this->insertButtonCode(iniConfig, cInputEnterButtonKey, aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_CENTER); + 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(buttonCodeKey, false)) { @@ -712,23 +746,23 @@ void Configuration::insertButtonCode(boost::property_tree::ptree& iniConfig, con void Configuration::writeButtonCodes(boost::property_tree::ptree& iniConfig) { - iniConfig.put(cInputPlayButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::PLAY) != buttonCodes_.end()); - iniConfig.put(cInputPauseButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::PAUSE) != buttonCodes_.end()); - iniConfig.put(cInputTogglePlayButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::TOGGLE_PLAY) != buttonCodes_.end()); - iniConfig.put(cInputNextTrackButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::NEXT) != buttonCodes_.end()); - iniConfig.put(cInputPreviousTrackButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::PREV) != buttonCodes_.end()); - iniConfig.put(cInputHomeButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::HOME) != buttonCodes_.end()); - iniConfig.put(cInputPhoneButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::PHONE) != buttonCodes_.end()); - iniConfig.put(cInputCallEndButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::CALL_END) != buttonCodes_.end()); - iniConfig.put(cInputVoiceCommandButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::MICROPHONE_1) != buttonCodes_.end()); - iniConfig.put(cInputLeftButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::LEFT) != buttonCodes_.end()); - iniConfig.put(cInputRightButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::RIGHT) != buttonCodes_.end()); - iniConfig.put(cInputUpButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::UP) != buttonCodes_.end()); - iniConfig.put(cInputDownButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::DOWN) != buttonCodes_.end()); - iniConfig.put(cInputScrollWheelButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::SCROLL_WHEEL) != buttonCodes_.end()); - iniConfig.put(cInputBackButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::BACK) != buttonCodes_.end()); - iniConfig.put(cInputEnterButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::ENTER) != buttonCodes_.end()); - iniConfig.put(cInputNavButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aasdk::proto::enums::ButtonCode::NAVIGATION) != buttonCodes_.end()); + iniConfig.put(cInputPlayButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_PLAY) != buttonCodes_.end()); + iniConfig.put(cInputPauseButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_PAUSE) != buttonCodes_.end()); + iniConfig.put(cInputTogglePlayButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_PLAY_PAUSE) != buttonCodes_.end()); + iniConfig.put(cInputNextTrackButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_NEXT) != buttonCodes_.end()); + iniConfig.put(cInputPreviousTrackButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_PREVIOUS) != buttonCodes_.end()); + iniConfig.put(cInputHomeButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_HOME) != buttonCodes_.end()); + iniConfig.put(cInputPhoneButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_CALL) != buttonCodes_.end()); + iniConfig.put(cInputCallEndButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_ENDCALL) != buttonCodes_.end()); + iniConfig.put(cInputVoiceCommandButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_SEARCH) != buttonCodes_.end()); + iniConfig.put(cInputLeftButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_LEFT) != buttonCodes_.end()); + iniConfig.put(cInputRightButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_RIGHT) != buttonCodes_.end()); + iniConfig.put(cInputUpButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_UP) != buttonCodes_.end()); + iniConfig.put(cInputDownButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_DOWN) != buttonCodes_.end()); + iniConfig.put(cInputScrollWheelButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_ROTARY_CONTROLLER) != buttonCodes_.end()); + iniConfig.put(cInputBackButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_BACK) != buttonCodes_.end()); + iniConfig.put(cInputEnterButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_CENTER) != buttonCodes_.end()); + iniConfig.put(cInputNavButtonKey, std::find(buttonCodes_.begin(), buttonCodes_.end(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_NAVIGATION) != buttonCodes_.end()); } } diff --git a/src/autoapp/Projection/InputDevice.cpp b/src/autoapp/Projection/InputDevice.cpp index 8bf0e5a..808d3c8 100644 --- a/src/autoapp/Projection/InputDevice.cpp +++ b/src/autoapp/Projection/InputDevice.cpp @@ -83,91 +83,91 @@ bool InputDevice::eventFilter(QObject* obj, QEvent* event) bool InputDevice::handleKeyEvent(QEvent* event, QKeyEvent* key) { auto eventType = event->type() == QEvent::KeyPress ? ButtonEventType::PRESS : ButtonEventType::RELEASE; - aasdk::proto::enums::ButtonCode::Enum buttonCode; + aap_protobuf::service::media::sink::KeyCode buttonCode; WheelDirection wheelDirection = WheelDirection::NONE; switch(key->key()) { case Qt::Key_Return: case Qt::Key_Enter: - buttonCode = aasdk::proto::enums::ButtonCode::ENTER; + buttonCode = aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_CENTER; break; case Qt::Key_Left: - buttonCode = aasdk::proto::enums::ButtonCode::LEFT; + buttonCode = aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_LEFT; break; case Qt::Key_Right: - buttonCode = aasdk::proto::enums::ButtonCode::RIGHT; + buttonCode = aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_RIGHT; break; case Qt::Key_Up: - buttonCode = aasdk::proto::enums::ButtonCode::UP; + buttonCode = aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_UP; break; case Qt::Key_Down: - buttonCode = aasdk::proto::enums::ButtonCode::DOWN; + buttonCode = aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_DOWN; break; case Qt::Key_Escape: - buttonCode = aasdk::proto::enums::ButtonCode::BACK; + buttonCode = aap_protobuf::service::media::sink::KeyCode::KEYCODE_BACK; break; case Qt::Key_H: - buttonCode = aasdk::proto::enums::ButtonCode::HOME; + buttonCode = aap_protobuf::service::media::sink::KeyCode::KEYCODE_HOME; break; case Qt::Key_P: - buttonCode = aasdk::proto::enums::ButtonCode::PHONE; + buttonCode = aap_protobuf::service::media::sink::KeyCode::KEYCODE_CALL; break; case Qt::Key_O: - buttonCode = aasdk::proto::enums::ButtonCode::CALL_END; + buttonCode = aap_protobuf::service::media::sink::KeyCode::KEYCODE_ENDCALL; break; case Qt::Key_MediaPlay: case Qt::Key_X: - buttonCode = aasdk::proto::enums::ButtonCode::PLAY; + buttonCode = aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_PLAY; break; case Qt::Key_MediaPause: case Qt::Key_C: - buttonCode = aasdk::proto::enums::ButtonCode::PAUSE; + buttonCode = aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_PAUSE; break; case Qt::Key_MediaPrevious: case Qt::Key_V: - buttonCode = aasdk::proto::enums::ButtonCode::PREV; + buttonCode = aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_PREVIOUS; break; case Qt::Key_MediaTogglePlayPause: case Qt::Key_B: - buttonCode = aasdk::proto::enums::ButtonCode::TOGGLE_PLAY; + buttonCode = aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_PLAY_PAUSE; break; case Qt::Key_MediaNext: case Qt::Key_N: - buttonCode = aasdk::proto::enums::ButtonCode::NEXT; + buttonCode = aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_NEXT; break; case Qt::Key_M: - buttonCode = aasdk::proto::enums::ButtonCode::MICROPHONE_1; + buttonCode = aap_protobuf::service::media::sink::KeyCode::KEYCODE_SEARCH; break; case Qt::Key_1: wheelDirection = WheelDirection::LEFT; eventType = ButtonEventType::NONE; - buttonCode = aasdk::proto::enums::ButtonCode::SCROLL_WHEEL; + buttonCode = aap_protobuf::service::media::sink::KeyCode::KEYCODE_ROTARY_CONTROLLER; break; case Qt::Key_2: wheelDirection = WheelDirection::RIGHT; eventType = ButtonEventType::NONE; - buttonCode = aasdk::proto::enums::ButtonCode::SCROLL_WHEEL; + buttonCode = aap_protobuf::service::media::sink::KeyCode::KEYCODE_ROTARY_CONTROLLER; break; case Qt::Key_F: - buttonCode = aasdk::proto::enums::ButtonCode::NAVIGATION; + buttonCode = aap_protobuf::service::media::sink::KeyCode::KEYCODE_NAVIGATION; break; default: @@ -177,7 +177,7 @@ bool InputDevice::handleKeyEvent(QEvent* event, QKeyEvent* key) const auto& buttonCodes = this->getSupportedButtonCodes(); if(std::find(buttonCodes.begin(), buttonCodes.end(), buttonCode) != buttonCodes.end()) { - if(buttonCode != aasdk::proto::enums::ButtonCode::SCROLL_WHEEL || event->type() == QEvent::KeyRelease) + if(buttonCode != aap_protobuf::service::media::sink::KeyCode::KEYCODE_ROTARY_CONTROLLER || event->type() == QEvent::KeyRelease) { eventHandler_->onButtonEvent({eventType, wheelDirection, buttonCode}); } @@ -193,18 +193,18 @@ bool InputDevice::handleTouchEvent(QEvent* event) return true; } - aasdk::proto::enums::TouchAction::Enum type; + aap_protobuf::service::input::message::TouchAction type; switch(event->type()) { case QEvent::MouseButtonPress: - type = aasdk::proto::enums::TouchAction::PRESS; + type = aap_protobuf::service::input::message::TouchAction::ACTION_DOWN; break; case QEvent::MouseButtonRelease: - type = aasdk::proto::enums::TouchAction::RELEASE; + type = aap_protobuf::service::input::message::TouchAction::ACTION_UP; break; case QEvent::MouseMove: - type = aasdk::proto::enums::TouchAction::DRAG; + type = aap_protobuf::service::input::message::TouchAction::ACTION_MOVED; break; default: return true; diff --git a/src/autoapp/Projection/OMXVideoOutput.cpp b/src/autoapp/Projection/OMXVideoOutput.cpp index f8f3808..6a46380 100644 --- a/src/autoapp/Projection/OMXVideoOutput.cpp +++ b/src/autoapp/Projection/OMXVideoOutput.cpp @@ -23,7 +23,7 @@ extern "C" #include } -#include +#include #include #include diff --git a/src/autoapp/Projection/RtAudioOutput.cpp b/src/autoapp/Projection/RtAudioOutput.cpp index aa12a8a..a59ea4b 100644 --- a/src/autoapp/Projection/RtAudioOutput.cpp +++ b/src/autoapp/Projection/RtAudioOutput.cpp @@ -33,9 +33,15 @@ RtAudioOutput::RtAudioOutput(uint32_t channelCount, uint32_t sampleSize, uint32_ , sampleSize_(sampleSize) , sampleRate_(sampleRate) { - std::vector apis; - RtAudio::getCompiledApi(apis); - dac_ = std::find(apis.begin(), apis.end(), RtAudio::LINUX_PULSE) == apis.end() ? std::make_unique() : std::make_unique(RtAudio::LINUX_PULSE); + + std::vector apis; + RtAudio::getCompiledApi(apis); + dac_ = std::find(apis.begin(), apis.end(), RtAudio::LINUX_PULSE) == apis.end() ? std::make_unique() : std::make_unique(RtAudio::LINUX_PULSE); + + // Set the error callback + dac_->setErrorCallback([](RtAudioErrorType type, const std::string& errorText) { + OPENAUTO_LOG(error) << "[RtAudioOutput] " << errorText; + }); } bool RtAudioOutput::open() @@ -54,13 +60,19 @@ bool RtAudioOutput::open() RtAudio::StreamOptions streamOptions; streamOptions.flags = RTAUDIO_MINIMIZE_LATENCY | RTAUDIO_SCHEDULE_REALTIME; 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(this), &streamOptions); dac_->openStream(¶meters, nullptr, RTAUDIO_SINT16, sampleRate_, &bufferFrames, &RtAudioOutput::audioBufferReadHandler, static_cast(this), &streamOptions); - OPENAUTO_LOG(info) << "[RtAudioOutput] Sample Rate: " << sampleRate_; - return audioBuffer_.open(QIODevice::ReadWrite); + if (result == RtAudioErrorType::RTAUDIO_NO_ERROR) { + 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 @@ -86,9 +98,10 @@ void RtAudioOutput::start() { 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(); } - 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(); } } } diff --git a/src/autoapp/Projection/VideoOutput.cpp b/src/autoapp/Projection/VideoOutput.cpp index dca398d..75edbd3 100644 --- a/src/autoapp/Projection/VideoOutput.cpp +++ b/src/autoapp/Projection/VideoOutput.cpp @@ -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(); } -aasdk::proto::enums::VideoResolution::Enum VideoOutput::getVideoResolution() const +aap_protobuf::service::media::shared::message::VideoCodecResolutionType VideoOutput::getVideoResolution() const { return configuration_->getVideoResolution(); } diff --git a/src/autoapp/Service/AndroidAutoEntity.cpp b/src/autoapp/Service/AndroidAutoEntity.cpp index 02986dd..3cea7f4 100644 --- a/src/autoapp/Service/AndroidAutoEntity.cpp +++ b/src/autoapp/Service/AndroidAutoEntity.cpp @@ -16,10 +16,64 @@ * along with openauto. If not, see . */ -#include +#include +#include +#include +#include +#include +#include +#include #include #include +/* + * 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 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 << "." << minorCode << ", 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."; this->triggerQuit(); @@ -164,8 +218,8 @@ void AndroidAutoEntity::onHandshake(const aasdk::common::DataConstBuffer& payloa { OPENAUTO_LOG(info) << "[AndroidAutoEntity] Auth completed."; - aasdk::proto::messages::AuthCompleteIndication authCompleteIndication; - authCompleteIndication.set_status(aasdk::proto::enums::Status::OK); + aap_protobuf::channel::control::auth::AuthResponse authCompleteIndication; + authCompleteIndication.set_status(aap_protobuf::shared::MessageStatus::STATUS_SUCCESS); auto authCompletePromise = aasdk::channel::SendPromise::defer(strand_); authCompletePromise->then([]() {}, std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(), std::placeholders::_1)); @@ -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() - << ", 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.set_head_unit_name("Crankshaft-NG"); - serviceDiscoveryResponse.set_car_model("Universal"); - serviceDiscoveryResponse.set_car_year("2018"); - serviceDiscoveryResponse.set_car_serial("20180301"); - serviceDiscoveryResponse.set_left_hand_drive_vehicle(configuration_->getHandednessOfTrafficType() == configuration::HandednessOfTrafficType::LEFT_HAND_DRIVE); - serviceDiscoveryResponse.set_headunit_manufacturer("f1x"); - serviceDiscoveryResponse.set_headunit_model("Crankshaft-NG Autoapp"); - serviceDiscoveryResponse.set_sw_build("1"); - serviceDiscoveryResponse.set_sw_version("1.0"); - serviceDiscoveryResponse.set_can_play_native_media_during_vr(false); - serviceDiscoveryResponse.set_hide_clock(!configuration_->showClock()); + + //serviceDiscoveryResponse.set_headunit_sw_build("2024.10.15"); + //serviceDiscoveryResponse.set_headunit_sw_version("1"); + serviceDiscoveryResponse.set_display_name("JourneyOS"); + + serviceDiscoveryResponse.set_allocated_headunit_info(&headUnitInfo); + + //serviceDiscoveryResponse.set_can_play_native_media_during_vr(false); 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()); } -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(); - aasdk::proto::enums::AudioFocusState::Enum audioFocusState = - request.audio_focus_type() == aasdk::proto::enums::AudioFocusType::RELEASE ? aasdk::proto::enums::AudioFocusState::LOSS - : aasdk::proto::enums::AudioFocusState::GAIN; + aap_protobuf::channel::control::focus::audio::notification::AudioFocusStateType audioFocusState = + request.audio_focus_type() == aap_protobuf::channel::control::focus::audio::event::AudioFocusRequestType::AUDIO_FOCUS_RELEASE + ? 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; - aasdk::proto::messages::AudioFocusResponse response; + aap_protobuf::channel::control::focus::audio::notification::AudioFocusNotification response; response.set_audio_focus_state(audioFocusState); 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()); } -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(); - aasdk::proto::messages::ShutdownResponse response; + aap_protobuf::channel::control::byebye::notification::ByeByeResponse response; auto promise = aasdk::channel::SendPromise::defer(strand_); promise->then(std::bind(&AndroidAutoEntity::triggerQuit, this->shared_from_this()), std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(), std::placeholders::_1)); @@ -238,18 +316,18 @@ void AndroidAutoEntity::onShutdownRequest(const aasdk::proto::messages::Shutdown 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 "; 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; - response.set_type(2); + aap_protobuf::channel::control::focus::navigation::notification::NavFocusNotification response; + response.set_focus_type(aap_protobuf::channel::control::focus::navigation::shared::NavFocusType::NAV_FOCUS_PROJECTED); auto promise = aasdk::channel::SendPromise::defer(strand_); 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()); } -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(); pinger_->pong(); @@ -302,7 +390,7 @@ void AndroidAutoEntity::sendPing() auto promise = aasdk::channel::SendPromise::defer(strand_); 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::high_resolution_clock::now().time_since_epoch()); request.set_timestamp(timestamp.count()); controlServiceChannel_->sendPingRequest(request, std::move(promise)); diff --git a/src/autoapp/Service/AndroidAutoEntityFactory.cpp b/src/autoapp/Service/AndroidAutoEntityFactory.cpp index d833250..9f0ace8 100644 --- a/src/autoapp/Service/AndroidAutoEntityFactory.cpp +++ b/src/autoapp/Service/AndroidAutoEntityFactory.cpp @@ -16,14 +16,14 @@ * along with openauto. If not, see . */ -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/autoapp/Service/AudioInputService.cpp b/src/autoapp/Service/AudioInputService.cpp deleted file mode 100644 index 47e80da..0000000 --- a/src/autoapp/Service/AudioInputService.cpp +++ /dev/null @@ -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 . -*/ - -#include -#include -#include - -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(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(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::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)); - } -} - -} -} -} -} diff --git a/src/autoapp/Service/AudioService.cpp b/src/autoapp/Service/AudioService.cpp deleted file mode 100644 index 8db28a7..0000000 --- a/src/autoapp/Service/AudioService.cpp +++ /dev/null @@ -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 . -*/ - -#include -#include - -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(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()); -} - -} -} -} -} diff --git a/src/autoapp/Service/Bluetooth/BluetoothService.cpp b/src/autoapp/Service/Bluetooth/BluetoothService.cpp new file mode 100644 index 0000000..a9e7704 --- /dev/null +++ b/src/autoapp/Service/Bluetooth/BluetoothService.cpp @@ -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 . +*/ + +#include +#include + +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(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(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(); + } + + } + } + } + } +} \ No newline at end of file diff --git a/src/autoapp/Service/BluetoothService.cpp b/src/autoapp/Service/BluetoothService.cpp deleted file mode 100644 index 707febb..0000000 --- a/src/autoapp/Service/BluetoothService.cpp +++ /dev/null @@ -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 . -*/ - -#include -#include - -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(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(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(); -} - -} -} -} -} diff --git a/src/autoapp/Service/GenericNotification/GenericNotificationService.cpp b/src/autoapp/Service/GenericNotification/GenericNotificationService.cpp new file mode 100644 index 0000000..2d3116d --- /dev/null +++ b/src/autoapp/Service/GenericNotification/GenericNotificationService.cpp @@ -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 . +*/ + +#include +#include +#include +#include + +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(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(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(); + } + } + } + } + } +} \ No newline at end of file diff --git a/src/autoapp/Service/InputService.cpp b/src/autoapp/Service/InputService.cpp deleted file mode 100644 index f038bb6..0000000 --- a/src/autoapp/Service/InputService.cpp +++ /dev/null @@ -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 . -*/ - -#include -#include -#include - -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(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(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::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::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)); - }); -} - -} -} -} -} diff --git a/src/autoapp/Service/InputSource/InputSourceService.cpp b/src/autoapp/Service/InputSource/InputSourceService.cpp new file mode 100644 index 0000000..54aeb5b --- /dev/null +++ b/src/autoapp/Service/InputSource/InputSourceService.cpp @@ -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 . +*/ + +#include +#include +#include + +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(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(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::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::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)); + }); + } + + + + } + } + } + } +} \ No newline at end of file diff --git a/src/autoapp/Service/MediaBrowser/MediaBrowserService.cpp b/src/autoapp/Service/MediaBrowser/MediaBrowserService.cpp new file mode 100644 index 0000000..4d6d9bd --- /dev/null +++ b/src/autoapp/Service/MediaBrowser/MediaBrowserService.cpp @@ -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 . +*/ + +#include +#include +#include +#include + +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(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(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(); + } + } + } + } + } +} \ No newline at end of file diff --git a/src/autoapp/Service/MediaPlaybackStatus/MediaPlaybackStatusService.cpp b/src/autoapp/Service/MediaPlaybackStatus/MediaPlaybackStatusService.cpp new file mode 100644 index 0000000..4a2ad10 --- /dev/null +++ b/src/autoapp/Service/MediaPlaybackStatus/MediaPlaybackStatusService.cpp @@ -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 . +*/ + +#include +#include +#include +#include + +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(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(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(); + } + } + } + } + } +} \ No newline at end of file diff --git a/src/autoapp/Service/MediaSink/AudioMediaSinkService.cpp b/src/autoapp/Service/MediaSink/AudioMediaSinkService.cpp new file mode 100644 index 0000000..802d765 --- /dev/null +++ b/src/autoapp/Service/MediaSink/AudioMediaSinkService.cpp @@ -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 . +*/ + +#include +#include + +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(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); + } + + + } + } + } + } +} \ No newline at end of file diff --git a/src/autoapp/Service/MediaSink/GuidanceAudioService.cpp b/src/autoapp/Service/MediaSink/GuidanceAudioService.cpp new file mode 100644 index 0000000..1acf33a --- /dev/null +++ b/src/autoapp/Service/MediaSink/GuidanceAudioService.cpp @@ -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 . +*/ + +#include + +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(strand_, std::move(messenger)), + std::move(audioOutput)) { + + } + } + } + } + } +} \ No newline at end of file diff --git a/src/autoapp/Service/MediaSink/MediaAudioService.cpp b/src/autoapp/Service/MediaSink/MediaAudioService.cpp new file mode 100644 index 0000000..73e3901 --- /dev/null +++ b/src/autoapp/Service/MediaSink/MediaAudioService.cpp @@ -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 . +*/ + +#include + + + +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(strand_, + std::move( + messenger)), + std::move(audioOutput)) { + + } + } + } + } + } +} \ No newline at end of file diff --git a/src/autoapp/Service/MediaSink/SystemAudioService.cpp b/src/autoapp/Service/MediaSink/SystemAudioService.cpp new file mode 100644 index 0000000..373ae84 --- /dev/null +++ b/src/autoapp/Service/MediaSink/SystemAudioService.cpp @@ -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 . +*/ + +#include +#include +#include + +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(strand_, + std::move(messenger)), + std::move(audioOutput)) { + + } + + } + } + } + } +} \ No newline at end of file diff --git a/src/autoapp/Service/MediaSink/TelephonyAudioService.cpp b/src/autoapp/Service/MediaSink/TelephonyAudioService.cpp new file mode 100644 index 0000000..5c7fa2b --- /dev/null +++ b/src/autoapp/Service/MediaSink/TelephonyAudioService.cpp @@ -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 . +*/ + +#include +#include +#include + +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(strand_, + std::move( + messenger)), + std::move(audioOutput)) { + + } + } + } + } + } +} \ No newline at end of file diff --git a/src/autoapp/Service/MediaSink/VideoMediaSinkService.cpp b/src/autoapp/Service/MediaSink/VideoMediaSinkService.cpp new file mode 100644 index 0000000..f672281 --- /dev/null +++ b/src/autoapp/Service/MediaSink/VideoMediaSinkService.cpp @@ -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 . +*/ + +#include +#include + +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(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)); + } + } + } + } + } +} \ No newline at end of file diff --git a/src/autoapp/Service/MediaSink/VideoService.cpp b/src/autoapp/Service/MediaSink/VideoService.cpp new file mode 100644 index 0000000..57917ff --- /dev/null +++ b/src/autoapp/Service/MediaSink/VideoService.cpp @@ -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 . +*/ + +#include +#include +#include + +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(strand_, + std::move( + messenger)), + std::move(videoOutput)) { + + } + } + } + } + } +} \ No newline at end of file diff --git a/src/autoapp/Service/MediaSource/MediaSourceService.cpp b/src/autoapp/Service/MediaSource/MediaSourceService.cpp new file mode 100644 index 0000000..dd98385 --- /dev/null +++ b/src/autoapp/Service/MediaSource/MediaSourceService.cpp @@ -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 . +*/ + +#include +#include +#include +#include + +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(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::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)); + } + } + } + } + } + } +} diff --git a/src/autoapp/Service/NavigationStatus/NavigationStatusService.cpp b/src/autoapp/Service/NavigationStatus/NavigationStatusService.cpp new file mode 100644 index 0000000..26ca1e3 --- /dev/null +++ b/src/autoapp/Service/NavigationStatus/NavigationStatusService.cpp @@ -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 . +*/ + +#include +#include +#include +#include + +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(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(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(); + } + } + } + } + } +} \ No newline at end of file diff --git a/src/autoapp/Service/PhoneStatus/PhoneStatusService.cpp b/src/autoapp/Service/PhoneStatus/PhoneStatusService.cpp new file mode 100644 index 0000000..79a78a5 --- /dev/null +++ b/src/autoapp/Service/PhoneStatus/PhoneStatusService.cpp @@ -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 . +*/ + +#include +#include +#include +#include + +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(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(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(); + } + + + } + } + } + } +} \ No newline at end of file diff --git a/src/autoapp/Service/Radio/RadioService.cpp b/src/autoapp/Service/Radio/RadioService.cpp new file mode 100644 index 0000000..d7d520a --- /dev/null +++ b/src/autoapp/Service/Radio/RadioService.cpp @@ -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 . +*/ + +#include +#include +#include +#include + +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(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(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(); + } + + + } + } + } + } +} \ No newline at end of file diff --git a/src/autoapp/Service/Sensor/SensorService.cpp b/src/autoapp/Service/Sensor/SensorService.cpp new file mode 100644 index 0000000..4db4bae --- /dev/null +++ b/src/autoapp/Service/Sensor/SensorService.cpp @@ -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 . +*/ + +#include +#include +#include +#include +#include +#include +#include + +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(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(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(); + } + } + } + } + } +} \ No newline at end of file diff --git a/src/autoapp/Service/SensorService.cpp b/src/autoapp/Service/SensorService.cpp deleted file mode 100644 index 851744e..0000000 --- a/src/autoapp/Service/SensorService.cpp +++ /dev/null @@ -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 . -*/ - -#include -#include -#include -#include -#include - -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(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(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(); -} - -} -} -} -} diff --git a/src/autoapp/Service/ServiceFactory.cpp b/src/autoapp/Service/ServiceFactory.cpp index 9ef2e70..e2ad415 100644 --- a/src/autoapp/Service/ServiceFactory.cpp +++ b/src/autoapp/Service/ServiceFactory.cpp @@ -18,18 +18,27 @@ #include #include -#include -#include -#include + +#include +#include +#include +#include + #include -#include -#include -#include -#include -#include -#include -#include -#include + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + #include #include #include @@ -39,124 +48,159 @@ #include #include #include -#include -namespace f1x -{ -namespace openauto -{ -namespace autoapp -{ -namespace service -{ -ServiceFactory::ServiceFactory(boost::asio::io_service& ioService, configuration::IConfiguration::Pointer configuration) - : ioService_(ioService) - , configuration_(std::move(configuration)) -{ +namespace f1x { + namespace openauto { + 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)); - serviceList.emplace_back(std::make_shared(ioService_, messenger, std::move(audioInput))); - this->createAudioServices(serviceList, messenger); - serviceList.emplace_back(std::make_shared(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(configuration_)); + // TODO: MEDIA SERVICE - 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(ioService_, messenger, std::move(audioInput))); + */ -IService::Pointer ServiceFactory::createVideoService(aasdk::messenger::IMessenger::Pointer messenger) -{ -#ifdef USE_OMX - auto videoOutput(std::make_shared(configuration_)); -#else - projection::IVideoOutput::Pointer videoOutput(new projection::QtVideoOutput(configuration_), std::bind(&QObject::deleteLater, std::placeholders::_1)); -#endif - return std::make_shared(ioService_, messenger, std::move(videoOutput)); -} -IService::Pointer ServiceFactory::createBluetoothService(aasdk::messenger::IMessenger::Pointer messenger) -{ - projection::IBluetoothDevice::Pointer bluetoothDevice; - switch(configuration_->getBluetoothAdapterType()) - { - case configuration::BluetoothAdapterType::LOCAL: - bluetoothDevice = projection::IBluetoothDevice::Pointer(new projection::LocalBluetoothDevice(), std::bind(&QObject::deleteLater, std::placeholders::_1)); - break; + this->createMediaSinkServices(serviceList, messenger); + this->createMediaSourceServices(serviceList, messenger); + serviceList.emplace_back(this->createSensorService(messenger)); + serviceList.emplace_back(this->createBluetoothService(messenger)); + serviceList.emplace_back(this->createInputService(messenger)); + serviceList.emplace_back(this->createWifiProjectionService(messenger)); - case configuration::BluetoothAdapterType::REMOTE: - bluetoothDevice = std::make_shared(configuration_->getBluetoothRemoteAdapterAddress()); - break; + return serviceList; + } - default: - bluetoothDevice = std::make_shared(); - break; - } + IService::Pointer ServiceFactory::createBluetoothService(aasdk::messenger::IMessenger::Pointer messenger) { + projection::IBluetoothDevice::Pointer bluetoothDevice; + switch (configuration_->getBluetoothAdapterType()) { + case configuration::BluetoothAdapterType::LOCAL: + bluetoothDevice = projection::IBluetoothDevice::Pointer(new projection::LocalBluetoothDevice(), + std::bind(&QObject::deleteLater, + std::placeholders::_1)); + break; - return std::make_shared(ioService_, messenger, std::move(bluetoothDevice)); -} + case configuration::BluetoothAdapterType::REMOTE: + bluetoothDevice = std::make_shared( + configuration_->getBluetoothRemoteAdapterAddress()); + break; -IService::Pointer ServiceFactory::createInputService(aasdk::messenger::IMessenger::Pointer messenger) -{ - QRect videoGeometry; - switch(configuration_->getVideoResolution()) - { - case aasdk::proto::enums::VideoResolution::_720p: - videoGeometry = QRect(0, 0, 1280, 720); - break; + default: + bluetoothDevice = std::make_shared(); + break; + } - case aasdk::proto::enums::VideoResolution::_1080p: - videoGeometry = QRect(0, 0, 1920, 1080); - break; + return std::make_shared(ioService_, messenger, std::move(bluetoothDevice)); + } - default: - videoGeometry = QRect(0, 0, 800, 480); - break; - } + IService::Pointer ServiceFactory::createInputService(aasdk::messenger::IMessenger::Pointer messenger) { + QRect videoGeometry; + switch (configuration_->getVideoResolution()) { + case aap_protobuf::service::media::shared::message::VideoCodecResolutionType::VIDEO_1280x720: + videoGeometry = QRect(0, 0, 1280, 720); + break; - QScreen* screen = QGuiApplication::primaryScreen(); - QRect screenGeometry = screen == nullptr ? QRect(0, 0, 1, 1) : screen->geometry(); - projection::IInputDevice::Pointer inputDevice(std::make_shared(*QApplication::instance(), configuration_, std::move(screenGeometry), std::move(videoGeometry))); + case aap_protobuf::service::media::shared::message::VideoCodecResolutionType::VIDEO_1920x1080: + videoGeometry = QRect(0, 0, 1920, 1080); + break; - return std::make_shared(ioService_, messenger, std::move(inputDevice)); -} + default: + videoGeometry = QRect(0, 0, 800, 480); + break; + } -void ServiceFactory::createAudioServices(ServiceList& serviceList, aasdk::messenger::IMessenger::Pointer messenger) -{ - if(configuration_->musicAudioChannelEnabled()) - { - auto mediaAudioOutput = configuration_->getAudioOutputBackendType() == configuration::AudioOutputBackendType::RTAUDIO ? - std::make_shared(2, 16, 48000) : - projection::IAudioOutput::Pointer(new projection::QtAudioOutput(2, 16, 48000), std::bind(&QObject::deleteLater, std::placeholders::_1)); + QScreen *screen = QGuiApplication::primaryScreen(); + QRect screenGeometry = screen == nullptr ? QRect(0, 0, 1, 1) : screen->geometry(); + projection::IInputDevice::Pointer inputDevice( + std::make_shared(*QApplication::instance(), configuration_, + std::move(screenGeometry), std::move(videoGeometry))); - serviceList.emplace_back(std::make_shared(ioService_, messenger, std::move(mediaAudioOutput))); - } + return std::make_shared(ioService_, messenger, std::move(inputDevice)); + } - if(configuration_->speechAudioChannelEnabled()) - { - auto speechAudioOutput = configuration_->getAudioOutputBackendType() == configuration::AudioOutputBackendType::RTAUDIO ? - std::make_shared(1, 16, 16000) : - projection::IAudioOutput::Pointer(new projection::QtAudioOutput(1, 16, 16000), std::bind(&QObject::deleteLater, std::placeholders::_1)); + void ServiceFactory::createMediaSinkServices(ServiceList &serviceList, + aasdk::messenger::IMessenger::Pointer messenger) { + if (configuration_->musicAudioChannelEnabled()) { + auto mediaAudioOutput = + configuration_->getAudioOutputBackendType() == configuration::AudioOutputBackendType::RTAUDIO ? + std::make_shared(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(ioService_, messenger, std::move(speechAudioOutput))); - } + serviceList.emplace_back( + std::make_shared(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(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(ioService_, messenger, std::move(systemAudioOutput))); -} + serviceList.emplace_back( + std::make_shared(ioService_, messenger, std::move(guidanceAudioOutput))); + } -} -} -} + if (configuration_->telephonyAudioChannelEnabled()) { + auto telephonyAudioOutput = + configuration_->getAudioOutputBackendType() == configuration::AudioOutputBackendType::RTAUDIO ? + std::make_shared(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(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(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(ioService_, messenger, std::move(systemAudioOutput))); + +#ifdef USE_OMX + auto videoOutput(std::make_shared(configuration_)); +#else + projection::IVideoOutput::Pointer videoOutput(new projection::QtVideoOutput(configuration_), + std::bind(&QObject::deleteLater, std::placeholders::_1)); +#endif + + serviceList.emplace_back( + std::make_shared(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(ioService_, messenger); + } + + IService::Pointer ServiceFactory::createWifiProjectionService(aasdk::messenger::IMessenger::Pointer messenger) { + return std::make_shared(ioService_, messenger); + } + + } + } + } } diff --git a/src/autoapp/Service/SpeechAudioService.cpp b/src/autoapp/Service/SpeechAudioService.cpp deleted file mode 100644 index 5930095..0000000 --- a/src/autoapp/Service/SpeechAudioService.cpp +++ /dev/null @@ -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 . -*/ - -#include -#include - -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(strand_, std::move(messenger)), std::move(audioOutput)) -{ - -} - -} -} -} -} diff --git a/src/autoapp/Service/SystemAudioService.cpp b/src/autoapp/Service/SystemAudioService.cpp deleted file mode 100644 index 0998615..0000000 --- a/src/autoapp/Service/SystemAudioService.cpp +++ /dev/null @@ -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 . -*/ - -#include -#include - -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(strand_, std::move(messenger)), std::move(audioOutput)) -{ - -} - -} -} -} -} diff --git a/src/autoapp/Service/VendorExtension/VendorExtensionService.cpp b/src/autoapp/Service/VendorExtension/VendorExtensionService.cpp new file mode 100644 index 0000000..cbbc9c1 --- /dev/null +++ b/src/autoapp/Service/VendorExtension/VendorExtensionService.cpp @@ -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 . +*/ + +#include +#include +#include +#include + +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(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(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(); + } + + + } + } + } + } +} \ No newline at end of file diff --git a/src/autoapp/Service/VideoService.cpp b/src/autoapp/Service/VideoService.cpp deleted file mode 100644 index 29a45b3..0000000 --- a/src/autoapp/Service/VideoService.cpp +++ /dev/null @@ -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 . -*/ - -#include -#include -#include - -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(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(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)); -} - -} -} -} -} diff --git a/src/autoapp/Service/WifiProjection/WifiProjectionStatus.cpp b/src/autoapp/Service/WifiProjection/WifiProjectionStatus.cpp new file mode 100644 index 0000000..58bcfbd --- /dev/null +++ b/src/autoapp/Service/WifiProjection/WifiProjectionStatus.cpp @@ -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 . +*/ + +#include +#include +#include +#include + +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(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(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(); + } + + + } + } + } + } +} \ No newline at end of file diff --git a/src/autoapp/Service/WifiService.cpp b/src/autoapp/Service/WifiService.cpp deleted file mode 100644 index f8d0d55..0000000 --- a/src/autoapp/Service/WifiService.cpp +++ /dev/null @@ -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 . -*/ - -#include -#include -#include -#include - -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()); -} - -} -} -} -} diff --git a/src/autoapp/UI/SettingsWindow.cpp b/src/autoapp/UI/SettingsWindow.cpp index de22f45..cceeec6 100644 --- a/src/autoapp/UI/SettingsWindow.cpp +++ b/src/autoapp/UI/SettingsWindow.cpp @@ -211,19 +211,19 @@ void SettingsWindow::onSave() configuration_->instantPlay(ui_->checkBoxInstantPlay->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()) { - configuration_->setVideoResolution(aasdk::proto::enums::VideoResolution::_480p); + configuration_->setVideoResolution(aap_protobuf::service::media::shared::message::VideoCodecResolutionType_480p); } 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()) { - configuration_->setVideoResolution(aasdk::proto::enums::VideoResolution::_1080p); + configuration_->setVideoResolution(aap_protobuf::service::media::shared::message::VideoCodecResolutionType_1080p); } configuration_->setScreenDPI(static_cast(ui_->horizontalSliderScreenDPI->value())); @@ -502,12 +502,12 @@ void SettingsWindow::load() ui_->checkBoxInstantPlay->setChecked(configuration_->instantPlay()); ui_->checkBoxDontShowAgain->setChecked(configuration_->hideWarning()); - ui_->radioButton30FPS->setChecked(configuration_->getVideoFPS() == aasdk::proto::enums::VideoFPS::_30); - ui_->radioButton60FPS->setChecked(configuration_->getVideoFPS() == aasdk::proto::enums::VideoFPS::_60); + ui_->radioButton30FPS->setChecked(configuration_->getVideoFPS() == aap_protobuf::service::media::shared::message::VideoFrameRateType::_30); + ui_->radioButton60FPS->setChecked(configuration_->getVideoFPS() == aap_protobuf::service::media::shared::message::VideoFrameRateType::_60); - ui_->radioButton480p->setChecked(configuration_->getVideoResolution() == aasdk::proto::enums::VideoResolution::_480p); - ui_->radioButton720p->setChecked(configuration_->getVideoResolution() == aasdk::proto::enums::VideoResolution::_720p); - ui_->radioButton1080p->setChecked(configuration_->getVideoResolution() == aasdk::proto::enums::VideoResolution::_1080p); + ui_->radioButton480p->setChecked(configuration_->getVideoResolution() == aap_protobuf::service::media::shared::message::VideoCodecResolutionType_480p); + ui_->radioButton720p->setChecked(configuration_->getVideoResolution() == aap_protobuf::service::media::shared::message::VideoCodecResolutionType_720p); + ui_->radioButton1080p->setChecked(configuration_->getVideoResolution() == aap_protobuf::service::media::shared::message::VideoCodecResolutionType_1080p); ui_->horizontalSliderScreenDPI->setValue(static_cast(configuration_->getScreenDPI())); ui_->spinBoxOmxLayerIndex->setValue(configuration_->getOMXLayerIndex()); @@ -549,23 +549,23 @@ void SettingsWindow::load() void SettingsWindow::loadButtonCheckBoxes() { const auto& buttonCodes = configuration_->getButtonCodes(); - ui_->checkBoxPlayButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aasdk::proto::enums::ButtonCode::PLAY) != buttonCodes.end()); - ui_->checkBoxPauseButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aasdk::proto::enums::ButtonCode::PAUSE) != buttonCodes.end()); - ui_->checkBoxTogglePlayButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aasdk::proto::enums::ButtonCode::TOGGLE_PLAY) != buttonCodes.end()); - ui_->checkBoxNextTrackButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aasdk::proto::enums::ButtonCode::NEXT) != buttonCodes.end()); - ui_->checkBoxPreviousTrackButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aasdk::proto::enums::ButtonCode::PREV) != buttonCodes.end()); - ui_->checkBoxHomeButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aasdk::proto::enums::ButtonCode::HOME) != buttonCodes.end()); - ui_->checkBoxPhoneButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aasdk::proto::enums::ButtonCode::PHONE) != buttonCodes.end()); - ui_->checkBoxCallEndButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aasdk::proto::enums::ButtonCode::CALL_END) != buttonCodes.end()); - ui_->checkBoxVoiceCommandButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aasdk::proto::enums::ButtonCode::MICROPHONE_1) != buttonCodes.end()); - ui_->checkBoxLeftButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aasdk::proto::enums::ButtonCode::LEFT) != buttonCodes.end()); - ui_->checkBoxRightButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aasdk::proto::enums::ButtonCode::RIGHT) != buttonCodes.end()); - ui_->checkBoxUpButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aasdk::proto::enums::ButtonCode::UP) != buttonCodes.end()); - ui_->checkBoxDownButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aasdk::proto::enums::ButtonCode::DOWN) != buttonCodes.end()); - ui_->checkBoxScrollWheelButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aasdk::proto::enums::ButtonCode::SCROLL_WHEEL) != buttonCodes.end()); - ui_->checkBoxBackButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aasdk::proto::enums::ButtonCode::BACK) != buttonCodes.end()); - ui_->checkBoxEnterButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aasdk::proto::enums::ButtonCode::ENTER) != buttonCodes.end()); - ui_->checkBoxNavButton->setChecked(std::find(buttonCodes.begin(), buttonCodes.end(), aasdk::proto::enums::ButtonCode::NAVIGATION) != 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(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_PAUSE) != 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(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_NEXT) != 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(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_HOME) != 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(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_ENDCALL) != 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(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_LEFT) != 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(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_UP) != 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(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_ROTARY_CONTROLLER) != 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(), aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_CENTER) != 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) @@ -592,27 +592,27 @@ void SettingsWindow::setButtonCheckBoxes(bool value) void SettingsWindow::saveButtonCheckBoxes() { configuration::IConfiguration::ButtonCodes buttonCodes; - this->saveButtonCheckBox(ui_->checkBoxPlayButton, buttonCodes, aasdk::proto::enums::ButtonCode::PLAY); - this->saveButtonCheckBox(ui_->checkBoxPauseButton, buttonCodes, aasdk::proto::enums::ButtonCode::PAUSE); - this->saveButtonCheckBox(ui_->checkBoxTogglePlayButton, buttonCodes, aasdk::proto::enums::ButtonCode::TOGGLE_PLAY); - this->saveButtonCheckBox(ui_->checkBoxNextTrackButton, buttonCodes, aasdk::proto::enums::ButtonCode::NEXT); - this->saveButtonCheckBox(ui_->checkBoxPreviousTrackButton, buttonCodes, aasdk::proto::enums::ButtonCode::PREV); - this->saveButtonCheckBox(ui_->checkBoxHomeButton, buttonCodes, aasdk::proto::enums::ButtonCode::HOME); - this->saveButtonCheckBox(ui_->checkBoxPhoneButton, buttonCodes, aasdk::proto::enums::ButtonCode::PHONE); - this->saveButtonCheckBox(ui_->checkBoxCallEndButton, buttonCodes, aasdk::proto::enums::ButtonCode::CALL_END); - this->saveButtonCheckBox(ui_->checkBoxVoiceCommandButton, buttonCodes, aasdk::proto::enums::ButtonCode::MICROPHONE_1); - this->saveButtonCheckBox(ui_->checkBoxLeftButton, buttonCodes, aasdk::proto::enums::ButtonCode::LEFT); - this->saveButtonCheckBox(ui_->checkBoxRightButton, buttonCodes, aasdk::proto::enums::ButtonCode::RIGHT); - this->saveButtonCheckBox(ui_->checkBoxUpButton, buttonCodes, aasdk::proto::enums::ButtonCode::UP); - this->saveButtonCheckBox(ui_->checkBoxDownButton, buttonCodes, aasdk::proto::enums::ButtonCode::DOWN); - this->saveButtonCheckBox(ui_->checkBoxScrollWheelButton, buttonCodes, aasdk::proto::enums::ButtonCode::SCROLL_WHEEL); - this->saveButtonCheckBox(ui_->checkBoxBackButton, buttonCodes, aasdk::proto::enums::ButtonCode::BACK); - this->saveButtonCheckBox(ui_->checkBoxEnterButton, buttonCodes, aasdk::proto::enums::ButtonCode::ENTER); - this->saveButtonCheckBox(ui_->checkBoxNavButton, buttonCodes, aasdk::proto::enums::ButtonCode::NAVIGATION); + this->saveButtonCheckBox(ui_->checkBoxPlayButton, buttonCodes, aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_PLAY); + this->saveButtonCheckBox(ui_->checkBoxPauseButton, buttonCodes, aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_PAUSE); + this->saveButtonCheckBox(ui_->checkBoxTogglePlayButton, buttonCodes, aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_PLAY_PAUSE); + this->saveButtonCheckBox(ui_->checkBoxNextTrackButton, buttonCodes, aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_NEXT); + this->saveButtonCheckBox(ui_->checkBoxPreviousTrackButton, buttonCodes, aap_protobuf::service::media::sink::KeyCode::KEYCODE_MEDIA_PREVIOUS); + this->saveButtonCheckBox(ui_->checkBoxHomeButton, buttonCodes, aap_protobuf::service::media::sink::KeyCode::KEYCODE_HOME); + this->saveButtonCheckBox(ui_->checkBoxPhoneButton, buttonCodes, aap_protobuf::service::media::sink::KeyCode::KEYCODE_CALL); + this->saveButtonCheckBox(ui_->checkBoxCallEndButton, buttonCodes, aap_protobuf::service::media::sink::KeyCode::KEYCODE_ENDCALL); + this->saveButtonCheckBox(ui_->checkBoxVoiceCommandButton, buttonCodes, aap_protobuf::service::media::sink::KeyCode::KEYCODE_SEARCH); + this->saveButtonCheckBox(ui_->checkBoxLeftButton, buttonCodes, aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_LEFT); + this->saveButtonCheckBox(ui_->checkBoxRightButton, buttonCodes, aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_RIGHT); + this->saveButtonCheckBox(ui_->checkBoxUpButton, buttonCodes, aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_UP); + this->saveButtonCheckBox(ui_->checkBoxDownButton, buttonCodes, aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_DOWN); + this->saveButtonCheckBox(ui_->checkBoxScrollWheelButton, buttonCodes, aap_protobuf::service::media::sink::KeyCode::KEYCODE_ROTARY_CONTROLLER); + this->saveButtonCheckBox(ui_->checkBoxBackButton, buttonCodes, aap_protobuf::service::media::sink::KeyCode::KEYCODE_BACK); + this->saveButtonCheckBox(ui_->checkBoxEnterButton, buttonCodes, aap_protobuf::service::media::sink::KeyCode::KEYCODE_DPAD_CENTER); + this->saveButtonCheckBox(ui_->checkBoxNavButton, buttonCodes, aap_protobuf::service::media::sink::KeyCode::KEYCODE_NAVIGATION); 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()) { diff --git a/src/autoapp/autoapp.cpp b/src/autoapp/autoapp.cpp index a2f1ea1..6493abb 100644 --- a/src/autoapp/autoapp.cpp +++ b/src/autoapp/autoapp.cpp @@ -19,12 +19,12 @@ #include #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -38,7 +38,7 @@ #include #include -namespace aasdk = f1x::aasdk; +namespace aasdk = aasdk; namespace autoapp = f1x::openauto::autoapp; using ThreadPool = std::vector; diff --git a/src/btservice/AndroidBluetoothServer.cpp b/src/btservice/AndroidBluetoothServer.cpp index ee3bfd6..0a8b702 100644 --- a/src/btservice/AndroidBluetoothServer.cpp +++ b/src/btservice/AndroidBluetoothServer.cpp @@ -23,9 +23,6 @@ #include #include #include -#include -#include -#include namespace f1x { namespace openauto { @@ -61,11 +58,11 @@ namespace f1x { // connect(socket, &QBluetoothSocket::disconnected, this, // QOverload<>::of(&ChatServer::clientDisconnected)); - f1x::aasdk::proto::messages::WifiInfoRequest request; - request.set_ip_address(getIP4_("wlan0")); - request.set_port(5000); + //aap_protobuf::messages::WifiInfoRequest request; + //request.set_ip_address(getIP4_("wlan0")); + //request.set_port(5000); - sendMessage(request, 1); + //sendMessage(request, 1); } else { OPENAUTO_LOG(error) << "[AndroidBluetoothServer] received null socket during client connection."; } @@ -93,7 +90,7 @@ namespace f1x { uint16_t messageId; stream >> messageId; - //OPENAUTO_LOG(info) << "[AndroidBluetoothServer] " << length << " " << messageId; + OPENAUTO_LOG(debug) << ""; switch (messageId) { case 1: @@ -121,28 +118,30 @@ namespace f1x { } void AndroidBluetoothServer::handleWifiInfoRequest(QByteArray &buffer, uint16_t length) { - f1x::aasdk::proto::messages::WifiInfoRequest msg; - msg.ParseFromArray(buffer.data() + 4, length); - OPENAUTO_LOG(info) << "WifiInfoRequest: " << msg.DebugString(); + //TODO: Restire + //aap_protobuf::messages::WifiInfoRequest msg; + //msg.ParseFromArray(buffer.data() + 4, length); + OPENAUTO_LOG(info) << "[AndroidBluetoothServer] WifiInfoRequest: "; //<< msg.DebugString(); - f1x::aasdk::proto::messages::WifiInfoResponse response; - response.set_ip_address(getIP4_("wlan0")); - response.set_port(5000); - response.set_status(aasdk::proto::messages::WifiInfoResponse_Status_STATUS_SUCCESS); + //aap_protobuf::messages::WifiInfoResponse response; + //response.set_ip_address(getIP4_("wlan0")); + //response.set_port(5000); + //response.set_status(aap_protobuf::messages::WifiInfoResponse_Status_STATUS_SUCCESS); - sendMessage(response, 7); + //sendMessage(response, 7); } 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_bssid(QNetworkInterface::interfaceFromName("wlan0").hardwareAddress().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_access_point_type(aasdk::proto::messages::WifiSecurityReponse_AccessPointType_STATIC); + //response.set_ssid(configuration_->getParamFromFile("/etc/hostapd/hostapd.conf","ssid").toStdString()); + //response.set_bssid(QNetworkInterface::interfaceFromName("wlan0").hardwareAddress().toStdString()); + //response.set_key(configuration_->getParamFromFile("/etc/hostapd/hostapd.conf","wpa_passphrase").toStdString()); + //response.set_security_mode(aap_protobuf::messages::WifiSecurityReponse_SecurityMode_WPA2_PERSONAL); + //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) { @@ -170,9 +169,10 @@ namespace f1x { } void AndroidBluetoothServer::handleWifiInfoRequestResponse(QByteArray &buffer, uint16_t length) { - f1x::aasdk::proto::messages::WifiInfoResponse msg; - msg.ParseFromArray(buffer.data() + 4, length); - OPENAUTO_LOG(info) << "WifiInfoResponse: " << msg.DebugString(); + OPENAUTO_LOG(info) << "[AndroidBluetoothServer] WifiInfoRequestResponse"; + //aap_protobuf::messages::WifiInfoResponse msg; + //msg.ParseFromArray(buffer.data() + 4, length); + //OPENAUTO_LOG(info) << "WifiInfoResponse: " << msg.DebugString(); } const ::std::string AndroidBluetoothServer::getIP4_(const QString intf) {