Merge remote-tracking branch 'remotes/origin/development'
This commit is contained in:
commit
bfaf8e1e60
@ -23,8 +23,8 @@
|
|||||||
#include <f1x/aasdk/USB/USBWrapper.hpp>
|
#include <f1x/aasdk/USB/USBWrapper.hpp>
|
||||||
#include <f1x/aasdk/TCP/ITCPWrapper.hpp>
|
#include <f1x/aasdk/TCP/ITCPWrapper.hpp>
|
||||||
#include <f1x/aasdk/TCP/ITCPEndpoint.hpp>
|
#include <f1x/aasdk/TCP/ITCPEndpoint.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/IAndroidAutoEntityEventHandler.hpp>
|
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntityEventHandler.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/IAndroidAutoEntityFactory.hpp>
|
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntityFactory.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
{
|
{
|
||||||
@ -33,12 +33,12 @@ namespace openauto
|
|||||||
namespace autoapp
|
namespace autoapp
|
||||||
{
|
{
|
||||||
|
|
||||||
class App: public projection::IAndroidAutoEntityEventHandler, public std::enable_shared_from_this<App>
|
class App: public service::IAndroidAutoEntityEventHandler, public std::enable_shared_from_this<App>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::shared_ptr<App> Pointer;
|
typedef std::shared_ptr<App> Pointer;
|
||||||
|
|
||||||
App(boost::asio::io_service& ioService, aasdk::usb::USBWrapper& usbWrapper, aasdk::tcp::ITCPWrapper& tcpWrapper, projection::IAndroidAutoEntityFactory& androidAutoEntityFactory,
|
App(boost::asio::io_service& ioService, aasdk::usb::USBWrapper& usbWrapper, aasdk::tcp::ITCPWrapper& tcpWrapper, service::IAndroidAutoEntityFactory& androidAutoEntityFactory,
|
||||||
aasdk::usb::IUSBHub::Pointer usbHub, aasdk::usb::IConnectedAccessoriesEnumerator::Pointer connectedAccessoriesEnumerator);
|
aasdk::usb::IUSBHub::Pointer usbHub, aasdk::usb::IConnectedAccessoriesEnumerator::Pointer connectedAccessoriesEnumerator);
|
||||||
|
|
||||||
void waitForUSBDevice();
|
void waitForUSBDevice();
|
||||||
@ -48,7 +48,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
using std::enable_shared_from_this<App>::shared_from_this;
|
using std::enable_shared_from_this<App>::shared_from_this;
|
||||||
|
|
||||||
void enumerateDevices();
|
void enumerateDevices();
|
||||||
void waitForDevice();
|
void waitForDevice();
|
||||||
void aoapDeviceHandler(aasdk::usb::DeviceHandle deviceHandle);
|
void aoapDeviceHandler(aasdk::usb::DeviceHandle deviceHandle);
|
||||||
@ -58,10 +57,10 @@ private:
|
|||||||
aasdk::usb::USBWrapper& usbWrapper_;
|
aasdk::usb::USBWrapper& usbWrapper_;
|
||||||
aasdk::tcp::ITCPWrapper& tcpWrapper_;
|
aasdk::tcp::ITCPWrapper& tcpWrapper_;
|
||||||
boost::asio::io_service::strand strand_;
|
boost::asio::io_service::strand strand_;
|
||||||
projection::IAndroidAutoEntityFactory& androidAutoEntityFactory_;
|
service::IAndroidAutoEntityFactory& androidAutoEntityFactory_;
|
||||||
aasdk::usb::IUSBHub::Pointer usbHub_;
|
aasdk::usb::IUSBHub::Pointer usbHub_;
|
||||||
aasdk::usb::IConnectedAccessoriesEnumerator::Pointer connectedAccessoriesEnumerator_;
|
aasdk::usb::IConnectedAccessoriesEnumerator::Pointer connectedAccessoriesEnumerator_;
|
||||||
projection::IAndroidAutoEntity::Pointer androidAutoEntity_;
|
service::IAndroidAutoEntity::Pointer androidAutoEntity_;
|
||||||
bool isStopped_;
|
bool isStopped_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -20,12 +20,13 @@
|
|||||||
|
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#include <f1x/aasdk/Transport/ITransport.hpp>
|
#include <f1x/aasdk/Transport/ITransport.hpp>
|
||||||
#include <f1x/aasdk/Channel/Control/ControlServiceChannel.hpp>
|
#include <f1x/aasdk/Channel/Control/IControlServiceChannel.hpp>
|
||||||
#include <f1x/aasdk/Channel/Control/IControlServiceChannelEventHandler.hpp>
|
#include <f1x/aasdk/Channel/Control/IControlServiceChannelEventHandler.hpp>
|
||||||
#include <f1x/aasdk/Channel/AV/VideoServiceChannel.hpp>
|
#include <f1x/aasdk/Channel/AV/VideoServiceChannel.hpp>
|
||||||
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/IAndroidAutoEntity.hpp>
|
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntity.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/IServiceFactory.hpp>
|
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
||||||
|
#include <f1x/openauto/autoapp/Service/IPinger.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
{
|
{
|
||||||
@ -33,7 +34,7 @@ namespace openauto
|
|||||||
{
|
{
|
||||||
namespace autoapp
|
namespace autoapp
|
||||||
{
|
{
|
||||||
namespace projection
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
class AndroidAutoEntity: public IAndroidAutoEntity, public aasdk::channel::control::IControlServiceChannelEventHandler, public std::enable_shared_from_this<AndroidAutoEntity>
|
class AndroidAutoEntity: public IAndroidAutoEntity, public aasdk::channel::control::IControlServiceChannelEventHandler, public std::enable_shared_from_this<AndroidAutoEntity>
|
||||||
@ -42,8 +43,10 @@ public:
|
|||||||
AndroidAutoEntity(boost::asio::io_service& ioService,
|
AndroidAutoEntity(boost::asio::io_service& ioService,
|
||||||
aasdk::messenger::ICryptor::Pointer cryptor,
|
aasdk::messenger::ICryptor::Pointer cryptor,
|
||||||
aasdk::transport::ITransport::Pointer transport,
|
aasdk::transport::ITransport::Pointer transport,
|
||||||
|
aasdk::messenger::IMessenger::Pointer messenger,
|
||||||
configuration::IConfiguration::Pointer configuration,
|
configuration::IConfiguration::Pointer configuration,
|
||||||
IServiceFactory& serviceFactory);
|
ServiceList serviceList,
|
||||||
|
IPinger::Pointer pinger);
|
||||||
~AndroidAutoEntity() override;
|
~AndroidAutoEntity() override;
|
||||||
|
|
||||||
void start(IAndroidAutoEntityEventHandler& eventHandler) override;
|
void start(IAndroidAutoEntityEventHandler& eventHandler) override;
|
||||||
@ -55,20 +58,23 @@ public:
|
|||||||
void onShutdownRequest(const aasdk::proto::messages::ShutdownRequest& request) override;
|
void onShutdownRequest(const aasdk::proto::messages::ShutdownRequest& request) override;
|
||||||
void onShutdownResponse(const aasdk::proto::messages::ShutdownResponse& response) override;
|
void onShutdownResponse(const aasdk::proto::messages::ShutdownResponse& response) override;
|
||||||
void onNavigationFocusRequest(const aasdk::proto::messages::NavigationFocusRequest& request) override;
|
void onNavigationFocusRequest(const aasdk::proto::messages::NavigationFocusRequest& request) override;
|
||||||
|
void onPingResponse(const aasdk::proto::messages::PingResponse& response) override;
|
||||||
void onChannelError(const aasdk::error::Error& e) override;
|
void onChannelError(const aasdk::error::Error& e) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using std::enable_shared_from_this<AndroidAutoEntity>::shared_from_this;
|
using std::enable_shared_from_this<AndroidAutoEntity>::shared_from_this;
|
||||||
void triggerQuit();
|
void triggerQuit();
|
||||||
|
void schedulePing();
|
||||||
|
void sendPing();
|
||||||
|
|
||||||
boost::asio::io_service::strand strand_;
|
boost::asio::io_service::strand strand_;
|
||||||
aasdk::messenger::ICryptor::Pointer cryptor_;
|
aasdk::messenger::ICryptor::Pointer cryptor_;
|
||||||
aasdk::transport::ITransport::Pointer transport_;
|
aasdk::transport::ITransport::Pointer transport_;
|
||||||
configuration::IConfiguration::Pointer configuration_;
|
|
||||||
IServiceFactory& serviceFactory_;
|
|
||||||
aasdk::messenger::IMessenger::Pointer messenger_;
|
aasdk::messenger::IMessenger::Pointer messenger_;
|
||||||
aasdk::channel::control::ControlServiceChannel::Pointer controlServiceChannel_;
|
aasdk::channel::control::IControlServiceChannel::Pointer controlServiceChannel_;
|
||||||
|
configuration::IConfiguration::Pointer configuration_;
|
||||||
ServiceList serviceList_;
|
ServiceList serviceList_;
|
||||||
|
IPinger::Pointer pinger_;
|
||||||
IAndroidAutoEntityEventHandler* eventHandler_;
|
IAndroidAutoEntityEventHandler* eventHandler_;
|
||||||
};
|
};
|
||||||
|
|
@ -21,8 +21,8 @@
|
|||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#include <f1x/aasdk/Transport/ITransport.hpp>
|
#include <f1x/aasdk/Transport/ITransport.hpp>
|
||||||
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/IAndroidAutoEntityFactory.hpp>
|
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntityFactory.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/IServiceFactory.hpp>
|
#include <f1x/openauto/autoapp/Service/IServiceFactory.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
{
|
{
|
||||||
@ -30,7 +30,7 @@ namespace openauto
|
|||||||
{
|
{
|
||||||
namespace autoapp
|
namespace autoapp
|
||||||
{
|
{
|
||||||
namespace projection
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
class AndroidAutoEntityFactory: public IAndroidAutoEntityFactory
|
class AndroidAutoEntityFactory: public IAndroidAutoEntityFactory
|
@ -19,7 +19,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <f1x/aasdk/Channel/AV/AVInputServiceChannel.hpp>
|
#include <f1x/aasdk/Channel/AV/AVInputServiceChannel.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/IService.hpp>
|
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/IAudioInput.hpp>
|
#include <f1x/openauto/autoapp/Projection/IAudioInput.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
@ -28,7 +28,7 @@ namespace openauto
|
|||||||
{
|
{
|
||||||
namespace autoapp
|
namespace autoapp
|
||||||
{
|
{
|
||||||
namespace projection
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
class AudioInputService: public aasdk::channel::av::IAVInputServiceChannelEventHandler, public IService, public std::enable_shared_from_this<AudioInputService>
|
class AudioInputService: public aasdk::channel::av::IAVInputServiceChannelEventHandler, public IService, public std::enable_shared_from_this<AudioInputService>
|
||||||
@ -36,7 +36,7 @@ class AudioInputService: public aasdk::channel::av::IAVInputServiceChannelEventH
|
|||||||
public:
|
public:
|
||||||
typedef std::shared_ptr<AudioInputService> Pointer;
|
typedef std::shared_ptr<AudioInputService> Pointer;
|
||||||
|
|
||||||
AudioInputService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, IAudioInput::Pointer audioInput);
|
AudioInputService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IAudioInput::Pointer audioInput);
|
||||||
|
|
||||||
void start() override;
|
void start() override;
|
||||||
void stop() override;
|
void stop() override;
|
||||||
@ -55,7 +55,7 @@ private:
|
|||||||
|
|
||||||
boost::asio::io_service::strand strand_;
|
boost::asio::io_service::strand strand_;
|
||||||
aasdk::channel::av::AVInputServiceChannel::Pointer channel_;
|
aasdk::channel::av::AVInputServiceChannel::Pointer channel_;
|
||||||
IAudioInput::Pointer audioInput_;
|
projection::IAudioInput::Pointer audioInput_;
|
||||||
int32_t session_;
|
int32_t session_;
|
||||||
};
|
};
|
||||||
|
|
@ -21,7 +21,7 @@
|
|||||||
#include <f1x/aasdk/Channel/AV/IAudioServiceChannel.hpp>
|
#include <f1x/aasdk/Channel/AV/IAudioServiceChannel.hpp>
|
||||||
#include <f1x/aasdk/Channel/AV/IAudioServiceChannelEventHandler.hpp>
|
#include <f1x/aasdk/Channel/AV/IAudioServiceChannelEventHandler.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/IAudioOutput.hpp>
|
#include <f1x/openauto/autoapp/Projection/IAudioOutput.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/IService.hpp>
|
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
{
|
{
|
||||||
@ -29,7 +29,7 @@ namespace openauto
|
|||||||
{
|
{
|
||||||
namespace autoapp
|
namespace autoapp
|
||||||
{
|
{
|
||||||
namespace projection
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
class AudioService: public aasdk::channel::av::IAudioServiceChannelEventHandler, public IService, public std::enable_shared_from_this<AudioService>
|
class AudioService: public aasdk::channel::av::IAudioServiceChannelEventHandler, public IService, public std::enable_shared_from_this<AudioService>
|
||||||
@ -37,7 +37,7 @@ class AudioService: public aasdk::channel::av::IAudioServiceChannelEventHandler,
|
|||||||
public:
|
public:
|
||||||
typedef std::shared_ptr<AudioService> Pointer;
|
typedef std::shared_ptr<AudioService> Pointer;
|
||||||
|
|
||||||
AudioService(boost::asio::io_service& ioService, aasdk::channel::av::IAudioServiceChannel::Pointer channel, IAudioOutput::Pointer audioOutput);
|
AudioService(boost::asio::io_service& ioService, aasdk::channel::av::IAudioServiceChannel::Pointer channel, projection::IAudioOutput::Pointer audioOutput);
|
||||||
|
|
||||||
void start() override;
|
void start() override;
|
||||||
void stop() override;
|
void stop() override;
|
||||||
@ -55,7 +55,7 @@ protected:
|
|||||||
|
|
||||||
boost::asio::io_service::strand strand_;
|
boost::asio::io_service::strand strand_;
|
||||||
aasdk::channel::av::IAudioServiceChannel::Pointer channel_;
|
aasdk::channel::av::IAudioServiceChannel::Pointer channel_;
|
||||||
IAudioOutput::Pointer audioOutput_;
|
projection::IAudioOutput::Pointer audioOutput_;
|
||||||
int32_t session_;
|
int32_t session_;
|
||||||
};
|
};
|
||||||
|
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include <f1x/aasdk/Channel/Bluetooth/BluetoothServiceChannel.hpp>
|
#include <f1x/aasdk/Channel/Bluetooth/BluetoothServiceChannel.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/IBluetoothDevice.hpp>
|
#include <f1x/openauto/autoapp/Projection/IBluetoothDevice.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/IService.hpp>
|
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
{
|
{
|
||||||
@ -28,13 +28,13 @@ namespace openauto
|
|||||||
{
|
{
|
||||||
namespace autoapp
|
namespace autoapp
|
||||||
{
|
{
|
||||||
namespace projection
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
class BluetoothService: public aasdk::channel::bluetooth::IBluetoothServiceChannelEventHandler, public IService, public std::enable_shared_from_this<BluetoothService>
|
class BluetoothService: public aasdk::channel::bluetooth::IBluetoothServiceChannelEventHandler, public IService, public std::enable_shared_from_this<BluetoothService>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BluetoothService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, IBluetoothDevice::Pointer bluetoothDevice);
|
BluetoothService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IBluetoothDevice::Pointer bluetoothDevice);
|
||||||
void start() override;
|
void start() override;
|
||||||
void stop() override;
|
void stop() override;
|
||||||
void fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response) override;
|
void fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response) override;
|
||||||
@ -47,7 +47,7 @@ private:
|
|||||||
|
|
||||||
boost::asio::io_service::strand strand_;
|
boost::asio::io_service::strand strand_;
|
||||||
aasdk::channel::bluetooth::BluetoothServiceChannel::Pointer channel_;
|
aasdk::channel::bluetooth::BluetoothServiceChannel::Pointer channel_;
|
||||||
IBluetoothDevice::Pointer bluetoothDevice_;
|
projection::IBluetoothDevice::Pointer bluetoothDevice_;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
@ -19,7 +19,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <f1x/openauto/autoapp/Projection/IAndroidAutoEntityEventHandler.hpp>
|
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntityEventHandler.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
{
|
{
|
||||||
@ -27,7 +27,7 @@ namespace openauto
|
|||||||
{
|
{
|
||||||
namespace autoapp
|
namespace autoapp
|
||||||
{
|
{
|
||||||
namespace projection
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
class IAndroidAutoEntity
|
class IAndroidAutoEntity
|
@ -26,7 +26,7 @@ namespace openauto
|
|||||||
{
|
{
|
||||||
namespace autoapp
|
namespace autoapp
|
||||||
{
|
{
|
||||||
namespace projection
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
class IAndroidAutoEntityEventHandler
|
class IAndroidAutoEntityEventHandler
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include <f1x/aasdk/TCP/ITCPEndpoint.hpp>
|
#include <f1x/aasdk/TCP/ITCPEndpoint.hpp>
|
||||||
#include <f1x/aasdk/USB/IAOAPDevice.hpp>
|
#include <f1x/aasdk/USB/IAOAPDevice.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/IAndroidAutoEntity.hpp>
|
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntity.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
{
|
{
|
||||||
@ -28,7 +28,7 @@ namespace openauto
|
|||||||
{
|
{
|
||||||
namespace autoapp
|
namespace autoapp
|
||||||
{
|
{
|
||||||
namespace projection
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
class IAndroidAutoEntityFactory
|
class IAndroidAutoEntityFactory
|
@ -26,10 +26,20 @@ namespace openauto
|
|||||||
{
|
{
|
||||||
namespace autoapp
|
namespace autoapp
|
||||||
{
|
{
|
||||||
namespace projection
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
typedef aasdk::io::Promise<void> ServiceFinishPromise;
|
class IPinger
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef std::shared_ptr<IPinger> Pointer;
|
||||||
|
typedef aasdk::io::Promise<void> Promise;
|
||||||
|
|
||||||
|
virtual ~IPinger() = default;
|
||||||
|
virtual void ping(Promise::Pointer promise) = 0;
|
||||||
|
virtual void pong() = 0;
|
||||||
|
virtual void cancel() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -28,7 +28,7 @@ namespace openauto
|
|||||||
{
|
{
|
||||||
namespace autoapp
|
namespace autoapp
|
||||||
{
|
{
|
||||||
namespace projection
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
class IService
|
class IService
|
@ -19,7 +19,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <f1x/aasdk/Messenger/IMessenger.hpp>
|
#include <f1x/aasdk/Messenger/IMessenger.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/IService.hpp>
|
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
{
|
{
|
||||||
@ -27,7 +27,7 @@ namespace openauto
|
|||||||
{
|
{
|
||||||
namespace autoapp
|
namespace autoapp
|
||||||
{
|
{
|
||||||
namespace projection
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
class IServiceFactory
|
class IServiceFactory
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include <aasdk_proto/ButtonCodeEnum.pb.h>
|
#include <aasdk_proto/ButtonCodeEnum.pb.h>
|
||||||
#include <f1x/aasdk/Channel/Input/InputServiceChannel.hpp>
|
#include <f1x/aasdk/Channel/Input/InputServiceChannel.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/IService.hpp>
|
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/IInputDevice.hpp>
|
#include <f1x/openauto/autoapp/Projection/IInputDevice.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/IInputDeviceEventHandler.hpp>
|
#include <f1x/openauto/autoapp/Projection/IInputDeviceEventHandler.hpp>
|
||||||
|
|
||||||
@ -30,17 +30,17 @@ namespace openauto
|
|||||||
{
|
{
|
||||||
namespace autoapp
|
namespace autoapp
|
||||||
{
|
{
|
||||||
namespace projection
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
class InputService:
|
class InputService:
|
||||||
public aasdk::channel::input::IInputServiceChannelEventHandler,
|
public aasdk::channel::input::IInputServiceChannelEventHandler,
|
||||||
public IService,
|
public IService,
|
||||||
public IInputDeviceEventHandler,
|
public projection::IInputDeviceEventHandler,
|
||||||
public std::enable_shared_from_this<InputService>
|
public std::enable_shared_from_this<InputService>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InputService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, IInputDevice::Pointer inputDevice);
|
InputService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IInputDevice::Pointer inputDevice);
|
||||||
|
|
||||||
void start() override;
|
void start() override;
|
||||||
void stop() override;
|
void stop() override;
|
||||||
@ -48,15 +48,15 @@ public:
|
|||||||
void onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request) override;
|
void onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request) override;
|
||||||
void onBindingRequest(const aasdk::proto::messages::BindingRequest& request) override;
|
void onBindingRequest(const aasdk::proto::messages::BindingRequest& request) override;
|
||||||
void onChannelError(const aasdk::error::Error& e) override;
|
void onChannelError(const aasdk::error::Error& e) override;
|
||||||
void onButtonEvent(const ButtonEvent& event) override;
|
void onButtonEvent(const projection::ButtonEvent& event) override;
|
||||||
void onTouchEvent(const TouchEvent& event) override;
|
void onTouchEvent(const projection::TouchEvent& event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using std::enable_shared_from_this<InputService>::shared_from_this;
|
using std::enable_shared_from_this<InputService>::shared_from_this;
|
||||||
|
|
||||||
boost::asio::io_service::strand strand_;
|
boost::asio::io_service::strand strand_;
|
||||||
aasdk::channel::input::InputServiceChannel::Pointer channel_;
|
aasdk::channel::input::InputServiceChannel::Pointer channel_;
|
||||||
IInputDevice::Pointer inputDevice_;
|
projection::IInputDevice::Pointer inputDevice_;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
@ -19,7 +19,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <f1x/aasdk/Messenger/IMessenger.hpp>
|
#include <f1x/aasdk/Messenger/IMessenger.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/AudioService.hpp>
|
#include <f1x/openauto/autoapp/Service/AudioService.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
{
|
{
|
||||||
@ -27,13 +27,13 @@ namespace openauto
|
|||||||
{
|
{
|
||||||
namespace autoapp
|
namespace autoapp
|
||||||
{
|
{
|
||||||
namespace projection
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
class MediaAudioService: public AudioService
|
class MediaAudioService: public AudioService
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MediaAudioService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, IAudioOutput::Pointer audioOutput);
|
MediaAudioService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IAudioOutput::Pointer audioOutput);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
58
include/f1x/openauto/autoapp/Service/Pinger.hpp
Normal file
58
include/f1x/openauto/autoapp/Service/Pinger.hpp
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of openauto project.
|
||||||
|
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||||
|
*
|
||||||
|
* openauto is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
|
||||||
|
* openauto is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <f1x/openauto/autoapp/Service/IPinger.hpp>
|
||||||
|
|
||||||
|
namespace f1x
|
||||||
|
{
|
||||||
|
namespace openauto
|
||||||
|
{
|
||||||
|
namespace autoapp
|
||||||
|
{
|
||||||
|
namespace service
|
||||||
|
{
|
||||||
|
|
||||||
|
class Pinger: public IPinger, public std::enable_shared_from_this<Pinger>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Pinger(boost::asio::io_service& ioService, time_t duration);
|
||||||
|
|
||||||
|
void ping(Promise::Pointer promise) override;
|
||||||
|
void pong() override;
|
||||||
|
void cancel() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
using std::enable_shared_from_this<Pinger>::shared_from_this;
|
||||||
|
|
||||||
|
void onTimerExceeded(const boost::system::error_code& error);
|
||||||
|
|
||||||
|
boost::asio::io_service::strand strand_;
|
||||||
|
boost::asio::deadline_timer timer_;
|
||||||
|
time_t duration_;
|
||||||
|
bool cancelled_;
|
||||||
|
Promise::Pointer promise_;
|
||||||
|
int64_t pingsCount_;
|
||||||
|
int64_t pongsCount_;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -19,7 +19,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <f1x/aasdk/Channel/Sensor/SensorServiceChannel.hpp>
|
#include <f1x/aasdk/Channel/Sensor/SensorServiceChannel.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/IService.hpp>
|
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
{
|
{
|
||||||
@ -27,7 +27,7 @@ namespace openauto
|
|||||||
{
|
{
|
||||||
namespace autoapp
|
namespace autoapp
|
||||||
{
|
{
|
||||||
namespace projection
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
class SensorService: public aasdk::channel::sensor::ISensorServiceChannelEventHandler, public IService, public std::enable_shared_from_this<SensorService>
|
class SensorService: public aasdk::channel::sensor::ISensorServiceChannelEventHandler, public IService, public std::enable_shared_from_this<SensorService>
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <f1x/openauto/autoapp/Projection/IServiceFactory.hpp>
|
#include <f1x/openauto/autoapp/Service/IServiceFactory.hpp>
|
||||||
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
@ -27,7 +27,7 @@ namespace openauto
|
|||||||
{
|
{
|
||||||
namespace autoapp
|
namespace autoapp
|
||||||
{
|
{
|
||||||
namespace projection
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
class ServiceFactory: public IServiceFactory
|
class ServiceFactory: public IServiceFactory
|
@ -19,7 +19,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <f1x/aasdk/Messenger/IMessenger.hpp>
|
#include <f1x/aasdk/Messenger/IMessenger.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/AudioService.hpp>
|
#include <f1x/openauto/autoapp/Service/AudioService.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
{
|
{
|
||||||
@ -27,13 +27,13 @@ namespace openauto
|
|||||||
{
|
{
|
||||||
namespace autoapp
|
namespace autoapp
|
||||||
{
|
{
|
||||||
namespace projection
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
class SpeechAudioService: public AudioService
|
class SpeechAudioService: public AudioService
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SpeechAudioService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, IAudioOutput::Pointer audioOutput);
|
SpeechAudioService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IAudioOutput::Pointer audioOutput);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
@ -19,7 +19,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <f1x/aasdk/Messenger/IMessenger.hpp>
|
#include <f1x/aasdk/Messenger/IMessenger.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/AudioService.hpp>
|
#include <f1x/openauto/autoapp/Service/AudioService.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
{
|
{
|
||||||
@ -27,13 +27,13 @@ namespace openauto
|
|||||||
{
|
{
|
||||||
namespace autoapp
|
namespace autoapp
|
||||||
{
|
{
|
||||||
namespace projection
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
class SystemAudioService: public AudioService
|
class SystemAudioService: public AudioService
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SystemAudioService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, IAudioOutput::Pointer audioOutput);
|
SystemAudioService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IAudioOutput::Pointer audioOutput);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
@ -21,9 +21,8 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <f1x/aasdk/Channel/AV/VideoServiceChannel.hpp>
|
#include <f1x/aasdk/Channel/AV/VideoServiceChannel.hpp>
|
||||||
#include <f1x/aasdk/Channel/AV/IVideoServiceChannelEventHandler.hpp>
|
#include <f1x/aasdk/Channel/AV/IVideoServiceChannelEventHandler.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/ServiceFinishPromise.hpp>
|
|
||||||
#include <f1x/openauto/autoapp/Projection/IVideoOutput.hpp>
|
#include <f1x/openauto/autoapp/Projection/IVideoOutput.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/IService.hpp>
|
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
{
|
{
|
||||||
@ -31,7 +30,7 @@ namespace openauto
|
|||||||
{
|
{
|
||||||
namespace autoapp
|
namespace autoapp
|
||||||
{
|
{
|
||||||
namespace projection
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
class VideoService: public aasdk::channel::av::IVideoServiceChannelEventHandler, public IService, public std::enable_shared_from_this<VideoService>
|
class VideoService: public aasdk::channel::av::IVideoServiceChannelEventHandler, public IService, public std::enable_shared_from_this<VideoService>
|
||||||
@ -39,7 +38,7 @@ class VideoService: public aasdk::channel::av::IVideoServiceChannelEventHandler,
|
|||||||
public:
|
public:
|
||||||
typedef std::shared_ptr<VideoService> Pointer;
|
typedef std::shared_ptr<VideoService> Pointer;
|
||||||
|
|
||||||
VideoService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, IVideoOutput::Pointer videoOutput);
|
VideoService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IVideoOutput::Pointer videoOutput);
|
||||||
|
|
||||||
void start() override;
|
void start() override;
|
||||||
void stop() override;
|
void stop() override;
|
||||||
@ -58,7 +57,7 @@ private:
|
|||||||
|
|
||||||
boost::asio::io_service::strand strand_;
|
boost::asio::io_service::strand strand_;
|
||||||
aasdk::channel::av::VideoServiceChannel::Pointer channel_;
|
aasdk::channel::av::VideoServiceChannel::Pointer channel_;
|
||||||
IVideoOutput::Pointer videoOutput_;
|
projection::IVideoOutput::Pointer videoOutput_;
|
||||||
int32_t session_;
|
int32_t session_;
|
||||||
};
|
};
|
||||||
|
|
@ -29,7 +29,7 @@ namespace openauto
|
|||||||
namespace autoapp
|
namespace autoapp
|
||||||
{
|
{
|
||||||
|
|
||||||
App::App(boost::asio::io_service& ioService, aasdk::usb::USBWrapper& usbWrapper, aasdk::tcp::ITCPWrapper& tcpWrapper, projection::IAndroidAutoEntityFactory& androidAutoEntityFactory,
|
App::App(boost::asio::io_service& ioService, aasdk::usb::USBWrapper& usbWrapper, aasdk::tcp::ITCPWrapper& tcpWrapper, service::IAndroidAutoEntityFactory& androidAutoEntityFactory,
|
||||||
aasdk::usb::IUSBHub::Pointer usbHub, aasdk::usb::IConnectedAccessoriesEnumerator::Pointer connectedAccessoriesEnumerator)
|
aasdk::usb::IUSBHub::Pointer usbHub, aasdk::usb::IConnectedAccessoriesEnumerator::Pointer connectedAccessoriesEnumerator)
|
||||||
: ioService_(ioService)
|
: ioService_(ioService)
|
||||||
, usbWrapper_(usbWrapper)
|
, usbWrapper_(usbWrapper)
|
||||||
@ -54,8 +54,13 @@ void App::waitForUSBDevice()
|
|||||||
void App::start(aasdk::tcp::ITCPEndpoint::SocketPointer socket)
|
void App::start(aasdk::tcp::ITCPEndpoint::SocketPointer socket)
|
||||||
{
|
{
|
||||||
strand_.dispatch([this, self = this->shared_from_this(), socket = std::move(socket)]() mutable {
|
strand_.dispatch([this, self = this->shared_from_this(), socket = std::move(socket)]() mutable {
|
||||||
if(androidAutoEntity_ == nullptr)
|
if(androidAutoEntity_ != nullptr)
|
||||||
{
|
{
|
||||||
|
tcpWrapper_.close(*socket);
|
||||||
|
OPENAUTO_LOG(warning) << "[App] android auto entity is still running.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
usbHub_->cancel();
|
usbHub_->cancel();
|
||||||
@ -72,12 +77,6 @@ void App::start(aasdk::tcp::ITCPEndpoint::SocketPointer socket)
|
|||||||
androidAutoEntity_.reset();
|
androidAutoEntity_.reset();
|
||||||
this->waitForDevice();
|
this->waitForDevice();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tcpWrapper_.close(*socket);
|
|
||||||
OPENAUTO_LOG(warning) << "[App] android auto entity is still running.";
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,6 +90,7 @@ void App::stop()
|
|||||||
if(androidAutoEntity_ != nullptr)
|
if(androidAutoEntity_ != nullptr)
|
||||||
{
|
{
|
||||||
androidAutoEntity_->stop();
|
androidAutoEntity_->stop();
|
||||||
|
androidAutoEntity_.reset();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -99,8 +99,12 @@ void App::aoapDeviceHandler(aasdk::usb::DeviceHandle deviceHandle)
|
|||||||
{
|
{
|
||||||
OPENAUTO_LOG(info) << "[App] Device connected.";
|
OPENAUTO_LOG(info) << "[App] Device connected.";
|
||||||
|
|
||||||
if(androidAutoEntity_ == nullptr)
|
if(androidAutoEntity_ != nullptr)
|
||||||
{
|
{
|
||||||
|
OPENAUTO_LOG(warning) << "[App] android auto entity is still running.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
connectedAccessoriesEnumerator_->cancel();
|
connectedAccessoriesEnumerator_->cancel();
|
||||||
@ -117,11 +121,6 @@ void App::aoapDeviceHandler(aasdk::usb::DeviceHandle deviceHandle)
|
|||||||
this->waitForDevice();
|
this->waitForDevice();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
OPENAUTO_LOG(warning) << "[App] android auto entity is still running.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void App::enumerateDevices()
|
void App::enumerateDevices()
|
||||||
{
|
{
|
||||||
@ -165,8 +164,8 @@ void App::onUSBHubError(const aasdk::error::Error& error)
|
|||||||
{
|
{
|
||||||
OPENAUTO_LOG(error) << "[App] usb hub error: " << error.what();
|
OPENAUTO_LOG(error) << "[App] usb hub error: " << error.what();
|
||||||
|
|
||||||
if(error.getCode() != aasdk::error::ErrorCode::OPERATION_ABORTED &&
|
if(error != aasdk::error::ErrorCode::OPERATION_ABORTED &&
|
||||||
error.getCode() != aasdk::error::ErrorCode::OPERATION_IN_PROGRESS)
|
error != aasdk::error::ErrorCode::OPERATION_IN_PROGRESS)
|
||||||
{
|
{
|
||||||
this->waitForDevice();
|
this->waitForDevice();
|
||||||
}
|
}
|
||||||
|
@ -16,10 +16,8 @@
|
|||||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <f1x/aasdk/Messenger/MessageInStream.hpp>
|
#include <f1x/aasdk/Channel/Control/ControlServiceChannel.hpp>
|
||||||
#include <f1x/aasdk/Messenger/MessageOutStream.hpp>
|
#include <f1x/openauto/autoapp/Service/AndroidAutoEntity.hpp>
|
||||||
#include <f1x/aasdk/Messenger/Messenger.hpp>
|
|
||||||
#include <f1x/openauto/autoapp/Projection/AndroidAutoEntity.hpp>
|
|
||||||
#include <f1x/openauto/Common/Log.hpp>
|
#include <f1x/openauto/Common/Log.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
@ -28,23 +26,24 @@ namespace openauto
|
|||||||
{
|
{
|
||||||
namespace autoapp
|
namespace autoapp
|
||||||
{
|
{
|
||||||
namespace projection
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
AndroidAutoEntity::AndroidAutoEntity(boost::asio::io_service& ioService,
|
AndroidAutoEntity::AndroidAutoEntity(boost::asio::io_service& ioService,
|
||||||
aasdk::messenger::ICryptor::Pointer cryptor,
|
aasdk::messenger::ICryptor::Pointer cryptor,
|
||||||
aasdk::transport::ITransport::Pointer transport,
|
aasdk::transport::ITransport::Pointer transport,
|
||||||
|
aasdk::messenger::IMessenger::Pointer messenger,
|
||||||
configuration::IConfiguration::Pointer configuration,
|
configuration::IConfiguration::Pointer configuration,
|
||||||
IServiceFactory& serviceFactory)
|
ServiceList serviceList,
|
||||||
|
IPinger::Pointer pinger)
|
||||||
: strand_(ioService)
|
: strand_(ioService)
|
||||||
, cryptor_(std::move(cryptor))
|
, cryptor_(std::move(cryptor))
|
||||||
, transport_(std::move(transport))
|
, transport_(std::move(transport))
|
||||||
, configuration_(std::move(configuration))
|
, messenger_(std::move(messenger))
|
||||||
, serviceFactory_(serviceFactory)
|
|
||||||
, messenger_(std::make_shared<aasdk::messenger::Messenger>(ioService,
|
|
||||||
std::make_shared<aasdk::messenger::MessageInStream>(ioService, transport_, cryptor_),
|
|
||||||
std::make_shared<aasdk::messenger::MessageOutStream>(ioService, transport_, cryptor_)))
|
|
||||||
, controlServiceChannel_(std::make_shared<aasdk::channel::control::ControlServiceChannel>(strand_, messenger_))
|
, controlServiceChannel_(std::make_shared<aasdk::channel::control::ControlServiceChannel>(strand_, messenger_))
|
||||||
|
, configuration_(std::move(configuration))
|
||||||
|
, serviceList_(std::move(serviceList))
|
||||||
|
, pinger_(std::move(pinger))
|
||||||
, eventHandler_(nullptr)
|
, eventHandler_(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -58,17 +57,15 @@ void AndroidAutoEntity::start(IAndroidAutoEntityEventHandler& eventHandler)
|
|||||||
{
|
{
|
||||||
strand_.dispatch([this, self = this->shared_from_this(), eventHandler = &eventHandler]() {
|
strand_.dispatch([this, self = this->shared_from_this(), eventHandler = &eventHandler]() {
|
||||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] start.";
|
OPENAUTO_LOG(info) << "[AndroidAutoEntity] start.";
|
||||||
|
|
||||||
eventHandler_ = eventHandler;
|
eventHandler_ = eventHandler;
|
||||||
|
|
||||||
cryptor_->init();
|
|
||||||
|
|
||||||
serviceList_ = serviceFactory_.create(messenger_);
|
|
||||||
std::for_each(serviceList_.begin(), serviceList_.end(), std::bind(&IService::start, std::placeholders::_1));
|
std::for_each(serviceList_.begin(), serviceList_.end(), std::bind(&IService::start, std::placeholders::_1));
|
||||||
|
this->schedulePing();
|
||||||
|
|
||||||
controlServiceChannel_->receive(this->shared_from_this());
|
|
||||||
auto versionRequestPromise = aasdk::channel::SendPromise::defer(strand_);
|
auto versionRequestPromise = aasdk::channel::SendPromise::defer(strand_);
|
||||||
versionRequestPromise->then([]() {}, std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
versionRequestPromise->then([]() {}, std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||||
controlServiceChannel_->sendVersionRequest(std::move(versionRequestPromise));
|
controlServiceChannel_->sendVersionRequest(std::move(versionRequestPromise));
|
||||||
|
controlServiceChannel_->receive(this->shared_from_this());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,12 +74,12 @@ void AndroidAutoEntity::stop()
|
|||||||
strand_.dispatch([this, self = this->shared_from_this()]() {
|
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] stop.";
|
OPENAUTO_LOG(info) << "[AndroidAutoEntity] stop.";
|
||||||
|
|
||||||
std::for_each(serviceList_.begin(), serviceList_.end(), std::bind(&IService::stop, std::placeholders::_1));
|
|
||||||
|
|
||||||
messenger_->stop();
|
|
||||||
cryptor_->deinit();
|
|
||||||
transport_->stop();
|
|
||||||
eventHandler_ = nullptr;
|
eventHandler_ = nullptr;
|
||||||
|
std::for_each(serviceList_.begin(), serviceList_.end(), std::bind(&IService::stop, std::placeholders::_1));
|
||||||
|
pinger_->cancel();
|
||||||
|
messenger_->stop();
|
||||||
|
transport_->stop();
|
||||||
|
cryptor_->deinit();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,13 +202,10 @@ void AndroidAutoEntity::onShutdownRequest(const aasdk::proto::messages::Shutdown
|
|||||||
|
|
||||||
aasdk::proto::messages::ShutdownResponse response;
|
aasdk::proto::messages::ShutdownResponse response;
|
||||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||||
promise->then([this, self = this->shared_from_this()]() {
|
promise->then(std::bind(&AndroidAutoEntity::triggerQuit, this->shared_from_this()),
|
||||||
this->triggerQuit();
|
|
||||||
},
|
|
||||||
std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||||
|
|
||||||
controlServiceChannel_->sendShutdownResponse(response, std::move(promise));
|
controlServiceChannel_->sendShutdownResponse(response, std::move(promise));
|
||||||
controlServiceChannel_->receive(this->shared_from_this());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidAutoEntity::onShutdownResponse(const aasdk::proto::messages::ShutdownResponse&)
|
void AndroidAutoEntity::onShutdownResponse(const aasdk::proto::messages::ShutdownResponse&)
|
||||||
@ -233,6 +227,12 @@ void AndroidAutoEntity::onNavigationFocusRequest(const aasdk::proto::messages::N
|
|||||||
controlServiceChannel_->receive(this->shared_from_this());
|
controlServiceChannel_->receive(this->shared_from_this());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AndroidAutoEntity::onPingResponse(const aasdk::proto::messages::PingResponse&)
|
||||||
|
{
|
||||||
|
pinger_->pong();
|
||||||
|
controlServiceChannel_->receive(this->shared_from_this());
|
||||||
|
}
|
||||||
|
|
||||||
void AndroidAutoEntity::onChannelError(const aasdk::error::Error& e)
|
void AndroidAutoEntity::onChannelError(const aasdk::error::Error& e)
|
||||||
{
|
{
|
||||||
OPENAUTO_LOG(error) << "[AndroidAutoEntity] channel error: " << e.what();
|
OPENAUTO_LOG(error) << "[AndroidAutoEntity] channel error: " << e.what();
|
||||||
@ -247,6 +247,34 @@ void AndroidAutoEntity::triggerQuit()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AndroidAutoEntity::schedulePing()
|
||||||
|
{
|
||||||
|
auto promise = IPinger::Promise::defer(strand_);
|
||||||
|
promise->then([this, self = this->shared_from_this()]() {
|
||||||
|
this->sendPing();
|
||||||
|
this->schedulePing();
|
||||||
|
},
|
||||||
|
[this, self = this->shared_from_this()](auto error) {
|
||||||
|
if(error != aasdk::error::ErrorCode::OPERATION_ABORTED &&
|
||||||
|
error != aasdk::error::ErrorCode::OPERATION_IN_PROGRESS)
|
||||||
|
{
|
||||||
|
OPENAUTO_LOG(error) << "[AndroidAutoEntity] ping timer exceeded.";
|
||||||
|
this->triggerQuit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
pinger_->ping(std::move(promise));
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
controlServiceChannel_->sendPingRequest(request, std::move(promise));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -21,8 +21,12 @@
|
|||||||
#include <f1x/aasdk/Transport/USBTransport.hpp>
|
#include <f1x/aasdk/Transport/USBTransport.hpp>
|
||||||
#include <f1x/aasdk/Transport/TCPTransport.hpp>
|
#include <f1x/aasdk/Transport/TCPTransport.hpp>
|
||||||
#include <f1x/aasdk/Messenger/Cryptor.hpp>
|
#include <f1x/aasdk/Messenger/Cryptor.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/AndroidAutoEntityFactory.hpp>
|
#include <f1x/aasdk/Messenger/MessageInStream.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/AndroidAutoEntity.hpp>
|
#include <f1x/aasdk/Messenger/MessageOutStream.hpp>
|
||||||
|
#include <f1x/aasdk/Messenger/Messenger.hpp>
|
||||||
|
#include <f1x/openauto/autoapp/Service/AndroidAutoEntityFactory.hpp>
|
||||||
|
#include <f1x/openauto/autoapp/Service/AndroidAutoEntity.hpp>
|
||||||
|
#include <f1x/openauto/autoapp/Service/Pinger.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
{
|
{
|
||||||
@ -30,7 +34,7 @@ namespace openauto
|
|||||||
{
|
{
|
||||||
namespace autoapp
|
namespace autoapp
|
||||||
{
|
{
|
||||||
namespace projection
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
AndroidAutoEntityFactory::AndroidAutoEntityFactory(boost::asio::io_service& ioService,
|
AndroidAutoEntityFactory::AndroidAutoEntityFactory(boost::asio::io_service& ioService,
|
||||||
@ -59,8 +63,15 @@ IAndroidAutoEntity::Pointer AndroidAutoEntityFactory::create(aasdk::transport::I
|
|||||||
{
|
{
|
||||||
auto sslWrapper(std::make_shared<aasdk::transport::SSLWrapper>());
|
auto sslWrapper(std::make_shared<aasdk::transport::SSLWrapper>());
|
||||||
auto cryptor(std::make_shared<aasdk::messenger::Cryptor>(std::move(sslWrapper)));
|
auto cryptor(std::make_shared<aasdk::messenger::Cryptor>(std::move(sslWrapper)));
|
||||||
|
cryptor->init();
|
||||||
|
|
||||||
return std::make_shared<AndroidAutoEntity>(ioService_, std::move(cryptor), std::move(transport), configuration_, serviceFactory_);
|
auto messenger(std::make_shared<aasdk::messenger::Messenger>(ioService_,
|
||||||
|
std::make_shared<aasdk::messenger::MessageInStream>(ioService_, transport, cryptor),
|
||||||
|
std::make_shared<aasdk::messenger::MessageOutStream>(ioService_, transport, cryptor)));
|
||||||
|
|
||||||
|
auto serviceList = serviceFactory_.create(messenger);
|
||||||
|
auto pinger(std::make_shared<Pinger>(ioService_, 5000));
|
||||||
|
return std::make_shared<AndroidAutoEntity>(ioService_, std::move(cryptor), std::move(transport), std::move(messenger), configuration_, std::move(serviceList), std::move(pinger));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <f1x/openauto/Common/Log.hpp>
|
#include <f1x/openauto/Common/Log.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/AudioInputService.hpp>
|
#include <f1x/openauto/autoapp/Service/AudioInputService.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
{
|
{
|
||||||
@ -26,10 +26,10 @@ namespace openauto
|
|||||||
{
|
{
|
||||||
namespace autoapp
|
namespace autoapp
|
||||||
{
|
{
|
||||||
namespace projection
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
AudioInputService::AudioInputService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, IAudioInput::Pointer audioInput)
|
AudioInputService::AudioInputService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IAudioInput::Pointer audioInput)
|
||||||
: strand_(ioService)
|
: strand_(ioService)
|
||||||
, channel_(std::make_shared<aasdk::channel::av::AVInputServiceChannel>(strand_, std::move(messenger)))
|
, channel_(std::make_shared<aasdk::channel::av::AVInputServiceChannel>(strand_, std::move(messenger)))
|
||||||
, audioInput_(std::move(audioInput))
|
, audioInput_(std::move(audioInput))
|
||||||
@ -114,7 +114,7 @@ void AudioInputService::onAVInputOpenRequest(const aasdk::proto::messages::AVInp
|
|||||||
|
|
||||||
if(request.open())
|
if(request.open())
|
||||||
{
|
{
|
||||||
auto startPromise = IAudioInput::StartPromise::defer(strand_);
|
auto startPromise = projection::IAudioInput::StartPromise::defer(strand_);
|
||||||
startPromise->then(std::bind(&AudioInputService::onAudioInputOpenSucceed, this->shared_from_this()),
|
startPromise->then(std::bind(&AudioInputService::onAudioInputOpenSucceed, this->shared_from_this()),
|
||||||
[this, self = this->shared_from_this()]() {
|
[this, self = this->shared_from_this()]() {
|
||||||
OPENAUTO_LOG(error) << "[AudioInputService] audio input open failed.";
|
OPENAUTO_LOG(error) << "[AudioInputService] audio input open failed.";
|
||||||
@ -185,7 +185,7 @@ void AudioInputService::readAudioInput()
|
|||||||
{
|
{
|
||||||
if(audioInput_->isActive())
|
if(audioInput_->isActive())
|
||||||
{
|
{
|
||||||
auto readPromise = IAudioInput::ReadPromise::defer(strand_);
|
auto readPromise = projection::IAudioInput::ReadPromise::defer(strand_);
|
||||||
readPromise->then(std::bind(&AudioInputService::onAudioInputDataReady, this->shared_from_this(), std::placeholders::_1),
|
readPromise->then(std::bind(&AudioInputService::onAudioInputDataReady, this->shared_from_this(), std::placeholders::_1),
|
||||||
[this, self = this->shared_from_this()]() {
|
[this, self = this->shared_from_this()]() {
|
||||||
OPENAUTO_LOG(info) << "[AudioInputService] audio input read rejected.";
|
OPENAUTO_LOG(info) << "[AudioInputService] audio input read rejected.";
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <f1x/openauto/Common/Log.hpp>
|
#include <f1x/openauto/Common/Log.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/AudioService.hpp>
|
#include <f1x/openauto/autoapp/Service/AudioService.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
{
|
{
|
||||||
@ -25,10 +25,10 @@ namespace openauto
|
|||||||
{
|
{
|
||||||
namespace autoapp
|
namespace autoapp
|
||||||
{
|
{
|
||||||
namespace projection
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
AudioService::AudioService(boost::asio::io_service& ioService, aasdk::channel::av::IAudioServiceChannel::Pointer channel, IAudioOutput::Pointer audioOutput)
|
AudioService::AudioService(boost::asio::io_service& ioService, aasdk::channel::av::IAudioServiceChannel::Pointer channel, projection::IAudioOutput::Pointer audioOutput)
|
||||||
: strand_(ioService)
|
: strand_(ioService)
|
||||||
, channel_(std::move(channel))
|
, channel_(std::move(channel))
|
||||||
, audioOutput_(std::move(audioOutput))
|
, audioOutput_(std::move(audioOutput))
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <f1x/openauto/Common/Log.hpp>
|
#include <f1x/openauto/Common/Log.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/BluetoothService.hpp>
|
#include <f1x/openauto/autoapp/Service/BluetoothService.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
{
|
{
|
||||||
@ -25,10 +25,10 @@ namespace openauto
|
|||||||
{
|
{
|
||||||
namespace autoapp
|
namespace autoapp
|
||||||
{
|
{
|
||||||
namespace projection
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
BluetoothService::BluetoothService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, IBluetoothDevice::Pointer bluetoothDevice)
|
BluetoothService::BluetoothService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IBluetoothDevice::Pointer bluetoothDevice)
|
||||||
: strand_(ioService)
|
: strand_(ioService)
|
||||||
, channel_(std::make_shared<aasdk::channel::bluetooth::BluetoothServiceChannel>(strand_, std::move(messenger)))
|
, channel_(std::make_shared<aasdk::channel::bluetooth::BluetoothServiceChannel>(strand_, std::move(messenger)))
|
||||||
, bluetoothDevice_(std::move(bluetoothDevice))
|
, bluetoothDevice_(std::move(bluetoothDevice))
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
#include <aasdk_proto/InputEventIndicationMessage.pb.h>
|
#include <aasdk_proto/InputEventIndicationMessage.pb.h>
|
||||||
#include <f1x/openauto/Common/Log.hpp>
|
#include <f1x/openauto/Common/Log.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/InputService.hpp>
|
#include <f1x/openauto/autoapp/Service/InputService.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
{
|
{
|
||||||
@ -26,10 +26,10 @@ namespace openauto
|
|||||||
{
|
{
|
||||||
namespace autoapp
|
namespace autoapp
|
||||||
{
|
{
|
||||||
namespace projection
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
InputService::InputService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, IInputDevice::Pointer inputDevice)
|
InputService::InputService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IInputDevice::Pointer inputDevice)
|
||||||
: strand_(ioService)
|
: strand_(ioService)
|
||||||
, channel_(std::make_shared<aasdk::channel::input::InputServiceChannel>(strand_, std::move(messenger)))
|
, channel_(std::make_shared<aasdk::channel::input::InputServiceChannel>(strand_, std::move(messenger)))
|
||||||
, inputDevice_(std::move(inputDevice))
|
, inputDevice_(std::move(inputDevice))
|
||||||
@ -135,7 +135,7 @@ void InputService::onChannelError(const aasdk::error::Error& e)
|
|||||||
OPENAUTO_LOG(error) << "[SensorService] channel error: " << e.what();
|
OPENAUTO_LOG(error) << "[SensorService] channel error: " << e.what();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputService::onButtonEvent(const ButtonEvent& event)
|
void InputService::onButtonEvent(const projection::ButtonEvent& event)
|
||||||
{
|
{
|
||||||
auto timestamp = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now().time_since_epoch());
|
auto timestamp = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now().time_since_epoch());
|
||||||
|
|
||||||
@ -146,14 +146,14 @@ void InputService::onButtonEvent(const ButtonEvent& event)
|
|||||||
if(event.code == aasdk::proto::enums::ButtonCode::SCROLL_WHEEL)
|
if(event.code == aasdk::proto::enums::ButtonCode::SCROLL_WHEEL)
|
||||||
{
|
{
|
||||||
auto relativeEvent = inputEventIndication.mutable_relative_input_event()->add_relative_input_events();
|
auto relativeEvent = inputEventIndication.mutable_relative_input_event()->add_relative_input_events();
|
||||||
relativeEvent->set_delta(event.wheelDirection == WheelDirection::LEFT ? -1 : 1);
|
relativeEvent->set_delta(event.wheelDirection == projection::WheelDirection::LEFT ? -1 : 1);
|
||||||
relativeEvent->set_scan_code(event.code);
|
relativeEvent->set_scan_code(event.code);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto buttonEvent = inputEventIndication.mutable_button_event()->add_button_events();
|
auto buttonEvent = inputEventIndication.mutable_button_event()->add_button_events();
|
||||||
buttonEvent->set_meta(0);
|
buttonEvent->set_meta(0);
|
||||||
buttonEvent->set_is_pressed(event.type == ButtonEventType::PRESS);
|
buttonEvent->set_is_pressed(event.type == projection::ButtonEventType::PRESS);
|
||||||
buttonEvent->set_long_press(false);
|
buttonEvent->set_long_press(false);
|
||||||
buttonEvent->set_scan_code(event.code);
|
buttonEvent->set_scan_code(event.code);
|
||||||
}
|
}
|
||||||
@ -164,7 +164,7 @@ void InputService::onButtonEvent(const ButtonEvent& event)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputService::onTouchEvent(const TouchEvent& event)
|
void InputService::onTouchEvent(const projection::TouchEvent& event)
|
||||||
{
|
{
|
||||||
auto timestamp = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now().time_since_epoch());
|
auto timestamp = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now().time_since_epoch());
|
||||||
|
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <f1x/aasdk/Channel/AV/MediaAudioServiceChannel.hpp>
|
#include <f1x/aasdk/Channel/AV/MediaAudioServiceChannel.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/MediaAudioService.hpp>
|
#include <f1x/openauto/autoapp/Service/MediaAudioService.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
{
|
{
|
||||||
@ -25,10 +25,10 @@ namespace openauto
|
|||||||
{
|
{
|
||||||
namespace autoapp
|
namespace autoapp
|
||||||
{
|
{
|
||||||
namespace projection
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
MediaAudioService::MediaAudioService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, IAudioOutput::Pointer audioOutput)
|
MediaAudioService::MediaAudioService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IAudioOutput::Pointer audioOutput)
|
||||||
: AudioService(ioService, std::make_shared<aasdk::channel::av::MediaAudioServiceChannel>(strand_, std::move(messenger)), std::move(audioOutput))
|
: AudioService(ioService, std::make_shared<aasdk::channel::av::MediaAudioServiceChannel>(strand_, std::move(messenger)), std::move(audioOutput))
|
||||||
{
|
{
|
||||||
|
|
101
src/autoapp/Service/Pinger.cpp
Normal file
101
src/autoapp/Service/Pinger.cpp
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of openauto project.
|
||||||
|
* Copyright (C) 2018 f1x.studio (Michal Szwaj)
|
||||||
|
*
|
||||||
|
* openauto is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
|
||||||
|
* openauto is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <f1x/openauto/autoapp/Service/Pinger.hpp>
|
||||||
|
|
||||||
|
namespace f1x
|
||||||
|
{
|
||||||
|
namespace openauto
|
||||||
|
{
|
||||||
|
namespace autoapp
|
||||||
|
{
|
||||||
|
namespace service
|
||||||
|
{
|
||||||
|
|
||||||
|
Pinger::Pinger(boost::asio::io_service& ioService, time_t duration)
|
||||||
|
: strand_(ioService)
|
||||||
|
, timer_(ioService)
|
||||||
|
, duration_(duration)
|
||||||
|
, cancelled_(false)
|
||||||
|
, pingsCount_(0)
|
||||||
|
, pongsCount_(0)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Pinger::ping(Promise::Pointer promise)
|
||||||
|
{
|
||||||
|
strand_.dispatch([this, self = this->shared_from_this(), promise = std::move(promise)]() mutable {
|
||||||
|
cancelled_ = false;
|
||||||
|
|
||||||
|
if(promise_ != nullptr)
|
||||||
|
{
|
||||||
|
promise_->reject(aasdk::error::Error(aasdk::error::ErrorCode::OPERATION_IN_PROGRESS));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
++pingsCount_;
|
||||||
|
|
||||||
|
promise_ = std::move(promise);
|
||||||
|
timer_.expires_from_now(boost::posix_time::milliseconds(duration_));
|
||||||
|
timer_.async_wait(strand_.wrap(std::bind(&Pinger::onTimerExceeded, this->shared_from_this(), std::placeholders::_1)));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void Pinger::pong()
|
||||||
|
{
|
||||||
|
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||||
|
++pongsCount_;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void Pinger::onTimerExceeded(const boost::system::error_code& error)
|
||||||
|
{
|
||||||
|
if(promise_ == nullptr)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(error == boost::asio::error::operation_aborted || cancelled_)
|
||||||
|
{
|
||||||
|
promise_->reject(aasdk::error::Error(aasdk::error::ErrorCode::OPERATION_ABORTED));
|
||||||
|
}
|
||||||
|
else if(pingsCount_ - pongsCount_ > 1)
|
||||||
|
{
|
||||||
|
promise_->reject(aasdk::error::Error());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
promise_->resolve();
|
||||||
|
}
|
||||||
|
|
||||||
|
promise_.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Pinger::cancel()
|
||||||
|
{
|
||||||
|
strand_.dispatch([this, self = this->shared_from_this()]() {
|
||||||
|
cancelled_ = true;
|
||||||
|
timer_.cancel();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
#include <aasdk_proto/DrivingStatusEnum.pb.h>
|
#include <aasdk_proto/DrivingStatusEnum.pb.h>
|
||||||
#include <f1x/openauto/Common/Log.hpp>
|
#include <f1x/openauto/Common/Log.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/SensorService.hpp>
|
#include <f1x/openauto/autoapp/Service/SensorService.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
{
|
{
|
||||||
@ -26,7 +26,7 @@ namespace openauto
|
|||||||
{
|
{
|
||||||
namespace autoapp
|
namespace autoapp
|
||||||
{
|
{
|
||||||
namespace projection
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
SensorService::SensorService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger)
|
SensorService::SensorService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger)
|
@ -21,15 +21,15 @@
|
|||||||
#include <f1x/aasdk/Channel/AV/MediaAudioServiceChannel.hpp>
|
#include <f1x/aasdk/Channel/AV/MediaAudioServiceChannel.hpp>
|
||||||
#include <f1x/aasdk/Channel/AV/SystemAudioServiceChannel.hpp>
|
#include <f1x/aasdk/Channel/AV/SystemAudioServiceChannel.hpp>
|
||||||
#include <f1x/aasdk/Channel/AV/SpeechAudioServiceChannel.hpp>
|
#include <f1x/aasdk/Channel/AV/SpeechAudioServiceChannel.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/ServiceFactory.hpp>
|
#include <f1x/openauto/autoapp/Service/ServiceFactory.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/VideoService.hpp>
|
#include <f1x/openauto/autoapp/Service/VideoService.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/MediaAudioService.hpp>
|
#include <f1x/openauto/autoapp/Service/MediaAudioService.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/SpeechAudioService.hpp>
|
#include <f1x/openauto/autoapp/Service/SpeechAudioService.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/SystemAudioService.hpp>
|
#include <f1x/openauto/autoapp/Service/SystemAudioService.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/AudioInputService.hpp>
|
#include <f1x/openauto/autoapp/Service/AudioInputService.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/SensorService.hpp>
|
#include <f1x/openauto/autoapp/Service/SensorService.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/BluetoothService.hpp>
|
#include <f1x/openauto/autoapp/Service/BluetoothService.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/InputService.hpp>
|
#include <f1x/openauto/autoapp/Service/InputService.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/QtVideoOutput.hpp>
|
#include <f1x/openauto/autoapp/Projection/QtVideoOutput.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/OMXVideoOutput.hpp>
|
#include <f1x/openauto/autoapp/Projection/OMXVideoOutput.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/RtAudioOutput.hpp>
|
#include <f1x/openauto/autoapp/Projection/RtAudioOutput.hpp>
|
||||||
@ -46,7 +46,7 @@ namespace openauto
|
|||||||
{
|
{
|
||||||
namespace autoapp
|
namespace autoapp
|
||||||
{
|
{
|
||||||
namespace projection
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
ServiceFactory::ServiceFactory(boost::asio::io_service& ioService, configuration::IConfiguration::Pointer configuration)
|
ServiceFactory::ServiceFactory(boost::asio::io_service& ioService, configuration::IConfiguration::Pointer configuration)
|
||||||
@ -60,7 +60,7 @@ ServiceList ServiceFactory::create(aasdk::messenger::IMessenger::Pointer messeng
|
|||||||
{
|
{
|
||||||
ServiceList serviceList;
|
ServiceList serviceList;
|
||||||
|
|
||||||
IAudioInput::Pointer audioInput(new QtAudioInput(1, 16, 16000), std::bind(&QObject::deleteLater, std::placeholders::_1));
|
projection::IAudioInput::Pointer audioInput(new projection::QtAudioInput(1, 16, 16000), std::bind(&QObject::deleteLater, std::placeholders::_1));
|
||||||
serviceList.emplace_back(std::make_shared<AudioInputService>(ioService_, messenger, std::move(audioInput)));
|
serviceList.emplace_back(std::make_shared<AudioInputService>(ioService_, messenger, std::move(audioInput)));
|
||||||
this->createAudioServices(serviceList, messenger);
|
this->createAudioServices(serviceList, messenger);
|
||||||
serviceList.emplace_back(std::make_shared<SensorService>(ioService_, messenger));
|
serviceList.emplace_back(std::make_shared<SensorService>(ioService_, messenger));
|
||||||
@ -74,28 +74,28 @@ ServiceList ServiceFactory::create(aasdk::messenger::IMessenger::Pointer messeng
|
|||||||
IService::Pointer ServiceFactory::createVideoService(aasdk::messenger::IMessenger::Pointer messenger)
|
IService::Pointer ServiceFactory::createVideoService(aasdk::messenger::IMessenger::Pointer messenger)
|
||||||
{
|
{
|
||||||
#ifdef USE_OMX
|
#ifdef USE_OMX
|
||||||
IVideoOutput::Pointer videoOutput(std::make_shared<OMXVideoOutput>(configuration_));
|
auto videoOutput(std::make_shared<projection::OMXVideoOutput>(configuration_));
|
||||||
#else
|
#else
|
||||||
IVideoOutput::Pointer videoOutput(new QtVideoOutput(configuration_), std::bind(&QObject::deleteLater, std::placeholders::_1));
|
projection::IVideoOutput::Pointer videoOutput(new projection::QtVideoOutput(configuration_), std::bind(&QObject::deleteLater, std::placeholders::_1));
|
||||||
#endif
|
#endif
|
||||||
return std::make_shared<VideoService>(ioService_, messenger, std::move(videoOutput));
|
return std::make_shared<VideoService>(ioService_, messenger, std::move(videoOutput));
|
||||||
}
|
}
|
||||||
|
|
||||||
IService::Pointer ServiceFactory::createBluetoothService(aasdk::messenger::IMessenger::Pointer messenger)
|
IService::Pointer ServiceFactory::createBluetoothService(aasdk::messenger::IMessenger::Pointer messenger)
|
||||||
{
|
{
|
||||||
IBluetoothDevice::Pointer bluetoothDevice;
|
projection::IBluetoothDevice::Pointer bluetoothDevice;
|
||||||
switch(configuration_->getBluetoothAdapterType())
|
switch(configuration_->getBluetoothAdapterType())
|
||||||
{
|
{
|
||||||
case configuration::BluetoothAdapterType::LOCAL:
|
case configuration::BluetoothAdapterType::LOCAL:
|
||||||
bluetoothDevice = IBluetoothDevice::Pointer(new LocalBluetoothDevice(), std::bind(&QObject::deleteLater, std::placeholders::_1));
|
bluetoothDevice = projection::IBluetoothDevice::Pointer(new projection::LocalBluetoothDevice(), std::bind(&QObject::deleteLater, std::placeholders::_1));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case configuration::BluetoothAdapterType::REMOTE:
|
case configuration::BluetoothAdapterType::REMOTE:
|
||||||
bluetoothDevice = std::make_shared<RemoteBluetoothDevice>(configuration_->getBluetoothRemoteAdapterAddress());
|
bluetoothDevice = std::make_shared<projection::RemoteBluetoothDevice>(configuration_->getBluetoothRemoteAdapterAddress());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
bluetoothDevice = std::make_shared<DummyBluetoothDevice>();
|
bluetoothDevice = std::make_shared<projection::DummyBluetoothDevice>();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ IService::Pointer ServiceFactory::createInputService(aasdk::messenger::IMessenge
|
|||||||
|
|
||||||
QScreen* screen = QGuiApplication::primaryScreen();
|
QScreen* screen = QGuiApplication::primaryScreen();
|
||||||
QRect screenGeometry = screen == nullptr ? QRect(0, 0, 1, 1) : screen->geometry();
|
QRect screenGeometry = screen == nullptr ? QRect(0, 0, 1, 1) : screen->geometry();
|
||||||
IInputDevice::Pointer inputDevice(std::make_shared<InputDevice>(*QApplication::instance(), configuration_, std::move(screenGeometry), std::move(videoGeometry)));
|
projection::IInputDevice::Pointer inputDevice(std::make_shared<projection::InputDevice>(*QApplication::instance(), configuration_, std::move(screenGeometry), std::move(videoGeometry)));
|
||||||
|
|
||||||
return std::make_shared<InputService>(ioService_, messenger, std::move(inputDevice));
|
return std::make_shared<InputService>(ioService_, messenger, std::move(inputDevice));
|
||||||
}
|
}
|
||||||
@ -132,8 +132,8 @@ void ServiceFactory::createAudioServices(ServiceList& serviceList, aasdk::messen
|
|||||||
if(configuration_->musicAudioChannelEnabled())
|
if(configuration_->musicAudioChannelEnabled())
|
||||||
{
|
{
|
||||||
auto mediaAudioOutput = configuration_->getAudioOutputBackendType() == configuration::AudioOutputBackendType::RTAUDIO ?
|
auto mediaAudioOutput = configuration_->getAudioOutputBackendType() == configuration::AudioOutputBackendType::RTAUDIO ?
|
||||||
std::make_shared<RtAudioOutput>(2, 16, 48000) :
|
std::make_shared<projection::RtAudioOutput>(2, 16, 48000) :
|
||||||
IAudioOutput::Pointer(new QtAudioOutput(2, 16, 48000), std::bind(&QObject::deleteLater, std::placeholders::_1));
|
projection::IAudioOutput::Pointer(new projection::QtAudioOutput(2, 16, 48000), std::bind(&QObject::deleteLater, std::placeholders::_1));
|
||||||
|
|
||||||
serviceList.emplace_back(std::make_shared<MediaAudioService>(ioService_, messenger, std::move(mediaAudioOutput)));
|
serviceList.emplace_back(std::make_shared<MediaAudioService>(ioService_, messenger, std::move(mediaAudioOutput)));
|
||||||
}
|
}
|
||||||
@ -141,15 +141,15 @@ void ServiceFactory::createAudioServices(ServiceList& serviceList, aasdk::messen
|
|||||||
if(configuration_->speechAudioChannelEnabled())
|
if(configuration_->speechAudioChannelEnabled())
|
||||||
{
|
{
|
||||||
auto speechAudioOutput = configuration_->getAudioOutputBackendType() == configuration::AudioOutputBackendType::RTAUDIO ?
|
auto speechAudioOutput = configuration_->getAudioOutputBackendType() == configuration::AudioOutputBackendType::RTAUDIO ?
|
||||||
std::make_shared<RtAudioOutput>(1, 16, 16000) :
|
std::make_shared<projection::RtAudioOutput>(1, 16, 16000) :
|
||||||
IAudioOutput::Pointer(new 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<SpeechAudioService>(ioService_, messenger, std::move(speechAudioOutput)));
|
serviceList.emplace_back(std::make_shared<SpeechAudioService>(ioService_, messenger, std::move(speechAudioOutput)));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto systemAudioOutput = configuration_->getAudioOutputBackendType() == configuration::AudioOutputBackendType::RTAUDIO ?
|
auto systemAudioOutput = configuration_->getAudioOutputBackendType() == configuration::AudioOutputBackendType::RTAUDIO ?
|
||||||
std::make_shared<RtAudioOutput>(1, 16, 16000) :
|
std::make_shared<projection::RtAudioOutput>(1, 16, 16000) :
|
||||||
IAudioOutput::Pointer(new QtAudioOutput(1, 16, 16000), std::bind(&QObject::deleteLater, std::placeholders::_1));
|
projection::IAudioOutput::Pointer(new projection::QtAudioOutput(1, 16, 16000), std::bind(&QObject::deleteLater, std::placeholders::_1));
|
||||||
|
|
||||||
serviceList.emplace_back(std::make_shared<SystemAudioService>(ioService_, messenger, std::move(systemAudioOutput)));
|
serviceList.emplace_back(std::make_shared<SystemAudioService>(ioService_, messenger, std::move(systemAudioOutput)));
|
||||||
}
|
}
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <f1x/aasdk/Channel/AV/SpeechAudioServiceChannel.hpp>
|
#include <f1x/aasdk/Channel/AV/SpeechAudioServiceChannel.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/SpeechAudioService.hpp>
|
#include <f1x/openauto/autoapp/Service/SpeechAudioService.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
{
|
{
|
||||||
@ -25,10 +25,10 @@ namespace openauto
|
|||||||
{
|
{
|
||||||
namespace autoapp
|
namespace autoapp
|
||||||
{
|
{
|
||||||
namespace projection
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
SpeechAudioService::SpeechAudioService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, IAudioOutput::Pointer audioOutput)
|
SpeechAudioService::SpeechAudioService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IAudioOutput::Pointer audioOutput)
|
||||||
: AudioService(ioService, std::make_shared<aasdk::channel::av::SpeechAudioServiceChannel>(strand_, std::move(messenger)), std::move(audioOutput))
|
: AudioService(ioService, std::make_shared<aasdk::channel::av::SpeechAudioServiceChannel>(strand_, std::move(messenger)), std::move(audioOutput))
|
||||||
{
|
{
|
||||||
|
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <f1x/aasdk/Channel/AV/SystemAudioServiceChannel.hpp>
|
#include <f1x/aasdk/Channel/AV/SystemAudioServiceChannel.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/SystemAudioService.hpp>
|
#include <f1x/openauto/autoapp/Service/SystemAudioService.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
{
|
{
|
||||||
@ -25,10 +25,10 @@ namespace openauto
|
|||||||
{
|
{
|
||||||
namespace autoapp
|
namespace autoapp
|
||||||
{
|
{
|
||||||
namespace projection
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
SystemAudioService::SystemAudioService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, IAudioOutput::Pointer audioOutput)
|
SystemAudioService::SystemAudioService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IAudioOutput::Pointer audioOutput)
|
||||||
: AudioService(ioService, std::make_shared<aasdk::channel::av::SystemAudioServiceChannel>(strand_, std::move(messenger)), std::move(audioOutput))
|
: AudioService(ioService, std::make_shared<aasdk::channel::av::SystemAudioServiceChannel>(strand_, std::move(messenger)), std::move(audioOutput))
|
||||||
{
|
{
|
||||||
|
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <f1x/openauto/Common/Log.hpp>
|
#include <f1x/openauto/Common/Log.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/VideoService.hpp>
|
#include <f1x/openauto/autoapp/Service/VideoService.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
{
|
{
|
||||||
@ -25,10 +25,10 @@ namespace openauto
|
|||||||
{
|
{
|
||||||
namespace autoapp
|
namespace autoapp
|
||||||
{
|
{
|
||||||
namespace projection
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
VideoService::VideoService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, IVideoOutput::Pointer videoOutput)
|
VideoService::VideoService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IVideoOutput::Pointer videoOutput)
|
||||||
: strand_(ioService)
|
: strand_(ioService)
|
||||||
, channel_(std::make_shared<aasdk::channel::av::VideoServiceChannel>(strand_, std::move(messenger)))
|
, channel_(std::make_shared<aasdk::channel::av::VideoServiceChannel>(strand_, std::move(messenger)))
|
||||||
, videoOutput_(std::move(videoOutput))
|
, videoOutput_(std::move(videoOutput))
|
@ -27,8 +27,8 @@
|
|||||||
#include <f1x/openauto/autoapp/App.hpp>
|
#include <f1x/openauto/autoapp/App.hpp>
|
||||||
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
||||||
#include <f1x/openauto/autoapp/Configuration/RecentAddressesList.hpp>
|
#include <f1x/openauto/autoapp/Configuration/RecentAddressesList.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/AndroidAutoEntityFactory.hpp>
|
#include <f1x/openauto/autoapp/Service/AndroidAutoEntityFactory.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/ServiceFactory.hpp>
|
#include <f1x/openauto/autoapp/Service/ServiceFactory.hpp>
|
||||||
#include <f1x/openauto/autoapp/Configuration/Configuration.hpp>
|
#include <f1x/openauto/autoapp/Configuration/Configuration.hpp>
|
||||||
#include <f1x/openauto/autoapp/UI/MainWindow.hpp>
|
#include <f1x/openauto/autoapp/UI/MainWindow.hpp>
|
||||||
#include <f1x/openauto/autoapp/UI/SettingsWindow.hpp>
|
#include <f1x/openauto/autoapp/UI/SettingsWindow.hpp>
|
||||||
@ -113,8 +113,8 @@ int main(int argc, char* argv[])
|
|||||||
aasdk::usb::USBWrapper usbWrapper(usbContext);
|
aasdk::usb::USBWrapper usbWrapper(usbContext);
|
||||||
aasdk::usb::AccessoryModeQueryFactory queryFactory(usbWrapper, ioService);
|
aasdk::usb::AccessoryModeQueryFactory queryFactory(usbWrapper, ioService);
|
||||||
aasdk::usb::AccessoryModeQueryChainFactory queryChainFactory(usbWrapper, ioService, queryFactory);
|
aasdk::usb::AccessoryModeQueryChainFactory queryChainFactory(usbWrapper, ioService, queryFactory);
|
||||||
autoapp::projection::ServiceFactory serviceFactory(ioService, configuration);
|
autoapp::service::ServiceFactory serviceFactory(ioService, configuration);
|
||||||
autoapp::projection::AndroidAutoEntityFactory androidAutoEntityFactory(ioService, configuration, serviceFactory);
|
autoapp::service::AndroidAutoEntityFactory androidAutoEntityFactory(ioService, configuration, serviceFactory);
|
||||||
|
|
||||||
auto usbHub(std::make_shared<aasdk::usb::USBHub>(usbWrapper, ioService, queryChainFactory));
|
auto usbHub(std::make_shared<aasdk::usb::USBHub>(usbWrapper, ioService, queryChainFactory));
|
||||||
auto connectedAccessoriesEnumerator(std::make_shared<aasdk::usb::ConnectedAccessoriesEnumerator>(usbWrapper, ioService, queryChainFactory));
|
auto connectedAccessoriesEnumerator(std::make_shared<aasdk::usb::ConnectedAccessoriesEnumerator>(usbWrapper, ioService, queryChainFactory));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user