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/TCP/ITCPWrapper.hpp>
|
||||
#include <f1x/aasdk/TCP/ITCPEndpoint.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/IAndroidAutoEntityEventHandler.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/IAndroidAutoEntityFactory.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntityEventHandler.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntityFactory.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
@ -33,12 +33,12 @@ namespace openauto
|
||||
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:
|
||||
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);
|
||||
|
||||
void waitForUSBDevice();
|
||||
@ -48,7 +48,6 @@ public:
|
||||
|
||||
private:
|
||||
using std::enable_shared_from_this<App>::shared_from_this;
|
||||
|
||||
void enumerateDevices();
|
||||
void waitForDevice();
|
||||
void aoapDeviceHandler(aasdk::usb::DeviceHandle deviceHandle);
|
||||
@ -58,10 +57,10 @@ private:
|
||||
aasdk::usb::USBWrapper& usbWrapper_;
|
||||
aasdk::tcp::ITCPWrapper& tcpWrapper_;
|
||||
boost::asio::io_service::strand strand_;
|
||||
projection::IAndroidAutoEntityFactory& androidAutoEntityFactory_;
|
||||
service::IAndroidAutoEntityFactory& androidAutoEntityFactory_;
|
||||
aasdk::usb::IUSBHub::Pointer usbHub_;
|
||||
aasdk::usb::IConnectedAccessoriesEnumerator::Pointer connectedAccessoriesEnumerator_;
|
||||
projection::IAndroidAutoEntity::Pointer androidAutoEntity_;
|
||||
service::IAndroidAutoEntity::Pointer androidAutoEntity_;
|
||||
bool isStopped_;
|
||||
};
|
||||
|
||||
|
@ -20,12 +20,13 @@
|
||||
|
||||
#include <boost/asio.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/AV/VideoServiceChannel.hpp>
|
||||
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/IAndroidAutoEntity.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/IServiceFactory.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntity.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/IPinger.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
@ -33,7 +34,7 @@ namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace projection
|
||||
namespace service
|
||||
{
|
||||
|
||||
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,
|
||||
aasdk::messenger::ICryptor::Pointer cryptor,
|
||||
aasdk::transport::ITransport::Pointer transport,
|
||||
aasdk::messenger::IMessenger::Pointer messenger,
|
||||
configuration::IConfiguration::Pointer configuration,
|
||||
IServiceFactory& serviceFactory);
|
||||
ServiceList serviceList,
|
||||
IPinger::Pointer pinger);
|
||||
~AndroidAutoEntity() override;
|
||||
|
||||
void start(IAndroidAutoEntityEventHandler& eventHandler) override;
|
||||
@ -55,20 +58,23 @@ public:
|
||||
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 onChannelError(const aasdk::error::Error& e) override;
|
||||
|
||||
private:
|
||||
using std::enable_shared_from_this<AndroidAutoEntity>::shared_from_this;
|
||||
void triggerQuit();
|
||||
void schedulePing();
|
||||
void sendPing();
|
||||
|
||||
boost::asio::io_service::strand strand_;
|
||||
aasdk::messenger::ICryptor::Pointer cryptor_;
|
||||
aasdk::transport::ITransport::Pointer transport_;
|
||||
configuration::IConfiguration::Pointer configuration_;
|
||||
IServiceFactory& serviceFactory_;
|
||||
aasdk::messenger::IMessenger::Pointer messenger_;
|
||||
aasdk::channel::control::ControlServiceChannel::Pointer controlServiceChannel_;
|
||||
aasdk::channel::control::IControlServiceChannel::Pointer controlServiceChannel_;
|
||||
configuration::IConfiguration::Pointer configuration_;
|
||||
ServiceList serviceList_;
|
||||
IPinger::Pointer pinger_;
|
||||
IAndroidAutoEntityEventHandler* eventHandler_;
|
||||
};
|
||||
|
@ -21,8 +21,8 @@
|
||||
#include <boost/asio.hpp>
|
||||
#include <f1x/aasdk/Transport/ITransport.hpp>
|
||||
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/IAndroidAutoEntityFactory.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/IServiceFactory.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntityFactory.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/IServiceFactory.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
@ -30,7 +30,7 @@ namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace projection
|
||||
namespace service
|
||||
{
|
||||
|
||||
class AndroidAutoEntityFactory: public IAndroidAutoEntityFactory
|
@ -19,7 +19,7 @@
|
||||
#pragma once
|
||||
|
||||
#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>
|
||||
|
||||
namespace f1x
|
||||
@ -28,7 +28,7 @@ namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace projection
|
||||
namespace service
|
||||
{
|
||||
|
||||
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:
|
||||
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 stop() override;
|
||||
@ -55,7 +55,7 @@ private:
|
||||
|
||||
boost::asio::io_service::strand strand_;
|
||||
aasdk::channel::av::AVInputServiceChannel::Pointer channel_;
|
||||
IAudioInput::Pointer audioInput_;
|
||||
projection::IAudioInput::Pointer audioInput_;
|
||||
int32_t session_;
|
||||
};
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include <f1x/aasdk/Channel/AV/IAudioServiceChannel.hpp>
|
||||
#include <f1x/aasdk/Channel/AV/IAudioServiceChannelEventHandler.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/IAudioOutput.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/IService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
@ -29,7 +29,7 @@ namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace projection
|
||||
namespace service
|
||||
{
|
||||
|
||||
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:
|
||||
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 stop() override;
|
||||
@ -55,7 +55,7 @@ protected:
|
||||
|
||||
boost::asio::io_service::strand strand_;
|
||||
aasdk::channel::av::IAudioServiceChannel::Pointer channel_;
|
||||
IAudioOutput::Pointer audioOutput_;
|
||||
projection::IAudioOutput::Pointer audioOutput_;
|
||||
int32_t session_;
|
||||
};
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
#include <f1x/aasdk/Channel/Bluetooth/BluetoothServiceChannel.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/IBluetoothDevice.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/IService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
@ -28,13 +28,13 @@ namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace projection
|
||||
namespace service
|
||||
{
|
||||
|
||||
class BluetoothService: public aasdk::channel::bluetooth::IBluetoothServiceChannelEventHandler, public IService, public std::enable_shared_from_this<BluetoothService>
|
||||
{
|
||||
public:
|
||||
BluetoothService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, IBluetoothDevice::Pointer bluetoothDevice);
|
||||
BluetoothService(boost::asio::io_service& ioService, aasdk::messenger::IMessenger::Pointer messenger, projection::IBluetoothDevice::Pointer bluetoothDevice);
|
||||
void start() override;
|
||||
void stop() override;
|
||||
void fillFeatures(aasdk::proto::messages::ServiceDiscoveryResponse& response) override;
|
||||
@ -47,7 +47,7 @@ private:
|
||||
|
||||
boost::asio::io_service::strand strand_;
|
||||
aasdk::channel::bluetooth::BluetoothServiceChannel::Pointer channel_;
|
||||
IBluetoothDevice::Pointer bluetoothDevice_;
|
||||
projection::IBluetoothDevice::Pointer bluetoothDevice_;
|
||||
};
|
||||
|
||||
}
|
@ -19,7 +19,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <f1x/openauto/autoapp/Projection/IAndroidAutoEntityEventHandler.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntityEventHandler.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
@ -27,7 +27,7 @@ namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace projection
|
||||
namespace service
|
||||
{
|
||||
|
||||
class IAndroidAutoEntity
|
@ -26,7 +26,7 @@ namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace projection
|
||||
namespace service
|
||||
{
|
||||
|
||||
class IAndroidAutoEntityEventHandler
|
@ -20,7 +20,7 @@
|
||||
|
||||
#include <f1x/aasdk/TCP/ITCPEndpoint.hpp>
|
||||
#include <f1x/aasdk/USB/IAOAPDevice.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/IAndroidAutoEntity.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/IAndroidAutoEntity.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
@ -28,7 +28,7 @@ namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace projection
|
||||
namespace service
|
||||
{
|
||||
|
||||
class IAndroidAutoEntityFactory
|
@ -26,10 +26,20 @@ namespace openauto
|
||||
{
|
||||
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 projection
|
||||
namespace service
|
||||
{
|
||||
|
||||
class IService
|
@ -19,7 +19,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <f1x/aasdk/Messenger/IMessenger.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/IService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
@ -27,7 +27,7 @@ namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace projection
|
||||
namespace service
|
||||
{
|
||||
|
||||
class IServiceFactory
|
@ -20,7 +20,7 @@
|
||||
|
||||
#include <aasdk_proto/ButtonCodeEnum.pb.h>
|
||||
#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/IInputDeviceEventHandler.hpp>
|
||||
|
||||
@ -30,17 +30,17 @@ namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace projection
|
||||
namespace service
|
||||
{
|
||||
|
||||
class InputService:
|
||||
public aasdk::channel::input::IInputServiceChannelEventHandler,
|
||||
public IService,
|
||||
public IInputDeviceEventHandler,
|
||||
public projection::IInputDeviceEventHandler,
|
||||
public std::enable_shared_from_this<InputService>
|
||||
{
|
||||
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 stop() override;
|
||||
@ -48,15 +48,15 @@ public:
|
||||
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 ButtonEvent& event) override;
|
||||
void onTouchEvent(const TouchEvent& event) override;
|
||||
void onButtonEvent(const projection::ButtonEvent& event) override;
|
||||
void onTouchEvent(const projection::TouchEvent& event) override;
|
||||
|
||||
private:
|
||||
using std::enable_shared_from_this<InputService>::shared_from_this;
|
||||
|
||||
boost::asio::io_service::strand strand_;
|
||||
aasdk::channel::input::InputServiceChannel::Pointer channel_;
|
||||
IInputDevice::Pointer inputDevice_;
|
||||
projection::IInputDevice::Pointer inputDevice_;
|
||||
};
|
||||
|
||||
}
|
@ -19,7 +19,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <f1x/aasdk/Messenger/IMessenger.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/AudioService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/AudioService.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
@ -27,13 +27,13 @@ namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace projection
|
||||
namespace service
|
||||
{
|
||||
|
||||
class MediaAudioService: public AudioService
|
||||
{
|
||||
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
|
||||
|
||||
#include <f1x/aasdk/Channel/Sensor/SensorServiceChannel.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/IService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
@ -27,7 +27,7 @@ namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace projection
|
||||
namespace service
|
||||
{
|
||||
|
||||
class SensorService: public aasdk::channel::sensor::ISensorServiceChannelEventHandler, public IService, public std::enable_shared_from_this<SensorService>
|
@ -18,7 +18,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <f1x/openauto/autoapp/Projection/IServiceFactory.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/IServiceFactory.hpp>
|
||||
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
||||
|
||||
namespace f1x
|
||||
@ -27,7 +27,7 @@ namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace projection
|
||||
namespace service
|
||||
{
|
||||
|
||||
class ServiceFactory: public IServiceFactory
|
@ -19,7 +19,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <f1x/aasdk/Messenger/IMessenger.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/AudioService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/AudioService.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
@ -27,13 +27,13 @@ namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace projection
|
||||
namespace service
|
||||
{
|
||||
|
||||
class SpeechAudioService: public AudioService
|
||||
{
|
||||
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
|
||||
|
||||
#include <f1x/aasdk/Messenger/IMessenger.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/AudioService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/AudioService.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
@ -27,13 +27,13 @@ namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace projection
|
||||
namespace service
|
||||
{
|
||||
|
||||
class SystemAudioService: public AudioService
|
||||
{
|
||||
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 <f1x/aasdk/Channel/AV/VideoServiceChannel.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/IService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/IService.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
@ -31,7 +30,7 @@ namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace projection
|
||||
namespace service
|
||||
{
|
||||
|
||||
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:
|
||||
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 stop() override;
|
||||
@ -58,7 +57,7 @@ private:
|
||||
|
||||
boost::asio::io_service::strand strand_;
|
||||
aasdk::channel::av::VideoServiceChannel::Pointer channel_;
|
||||
IVideoOutput::Pointer videoOutput_;
|
||||
projection::IVideoOutput::Pointer videoOutput_;
|
||||
int32_t session_;
|
||||
};
|
||||
|
@ -29,7 +29,7 @@ namespace openauto
|
||||
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)
|
||||
: ioService_(ioService)
|
||||
, usbWrapper_(usbWrapper)
|
||||
@ -54,29 +54,28 @@ void App::waitForUSBDevice()
|
||||
void App::start(aasdk::tcp::ITCPEndpoint::SocketPointer socket)
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this(), socket = std::move(socket)]() mutable {
|
||||
if(androidAutoEntity_ == nullptr)
|
||||
{
|
||||
try
|
||||
{
|
||||
usbHub_->cancel();
|
||||
connectedAccessoriesEnumerator_->cancel();
|
||||
|
||||
auto tcpEndpoint(std::make_shared<aasdk::tcp::TCPEndpoint>(tcpWrapper_, std::move(socket)));
|
||||
androidAutoEntity_ = androidAutoEntityFactory_.create(std::move(tcpEndpoint));
|
||||
androidAutoEntity_->start(*this);
|
||||
}
|
||||
catch(const aasdk::error::Error& error)
|
||||
{
|
||||
OPENAUTO_LOG(error) << "[App] TCP AndroidAutoEntity create error: " << error.what();
|
||||
|
||||
androidAutoEntity_.reset();
|
||||
this->waitForDevice();
|
||||
}
|
||||
}
|
||||
else
|
||||
if(androidAutoEntity_ != nullptr)
|
||||
{
|
||||
tcpWrapper_.close(*socket);
|
||||
OPENAUTO_LOG(warning) << "[App] android auto entity is still running.";
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
usbHub_->cancel();
|
||||
connectedAccessoriesEnumerator_->cancel();
|
||||
|
||||
auto tcpEndpoint(std::make_shared<aasdk::tcp::TCPEndpoint>(tcpWrapper_, std::move(socket)));
|
||||
androidAutoEntity_ = androidAutoEntityFactory_.create(std::move(tcpEndpoint));
|
||||
androidAutoEntity_->start(*this);
|
||||
}
|
||||
catch(const aasdk::error::Error& error)
|
||||
{
|
||||
OPENAUTO_LOG(error) << "[App] TCP AndroidAutoEntity create error: " << error.what();
|
||||
|
||||
androidAutoEntity_.reset();
|
||||
this->waitForDevice();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -91,6 +90,7 @@ void App::stop()
|
||||
if(androidAutoEntity_ != nullptr)
|
||||
{
|
||||
androidAutoEntity_->stop();
|
||||
androidAutoEntity_.reset();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -99,27 +99,26 @@ void App::aoapDeviceHandler(aasdk::usb::DeviceHandle deviceHandle)
|
||||
{
|
||||
OPENAUTO_LOG(info) << "[App] Device connected.";
|
||||
|
||||
if(androidAutoEntity_ == nullptr)
|
||||
{
|
||||
try
|
||||
{
|
||||
connectedAccessoriesEnumerator_->cancel();
|
||||
|
||||
auto aoapDevice(aasdk::usb::AOAPDevice::create(usbWrapper_, ioService_, deviceHandle));
|
||||
androidAutoEntity_ = androidAutoEntityFactory_.create(std::move(aoapDevice));
|
||||
androidAutoEntity_->start(*this);
|
||||
}
|
||||
catch(const aasdk::error::Error& error)
|
||||
{
|
||||
OPENAUTO_LOG(error) << "[App] USB AndroidAutoEntity create error: " << error.what();
|
||||
|
||||
androidAutoEntity_.reset();
|
||||
this->waitForDevice();
|
||||
}
|
||||
}
|
||||
else
|
||||
if(androidAutoEntity_ != nullptr)
|
||||
{
|
||||
OPENAUTO_LOG(warning) << "[App] android auto entity is still running.";
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
connectedAccessoriesEnumerator_->cancel();
|
||||
|
||||
auto aoapDevice(aasdk::usb::AOAPDevice::create(usbWrapper_, ioService_, deviceHandle));
|
||||
androidAutoEntity_ = androidAutoEntityFactory_.create(std::move(aoapDevice));
|
||||
androidAutoEntity_->start(*this);
|
||||
}
|
||||
catch(const aasdk::error::Error& error)
|
||||
{
|
||||
OPENAUTO_LOG(error) << "[App] USB AndroidAutoEntity create error: " << error.what();
|
||||
|
||||
androidAutoEntity_.reset();
|
||||
this->waitForDevice();
|
||||
}
|
||||
}
|
||||
|
||||
@ -165,8 +164,8 @@ void App::onUSBHubError(const aasdk::error::Error& error)
|
||||
{
|
||||
OPENAUTO_LOG(error) << "[App] usb hub error: " << error.what();
|
||||
|
||||
if(error.getCode() != aasdk::error::ErrorCode::OPERATION_ABORTED &&
|
||||
error.getCode() != aasdk::error::ErrorCode::OPERATION_IN_PROGRESS)
|
||||
if(error != aasdk::error::ErrorCode::OPERATION_ABORTED &&
|
||||
error != aasdk::error::ErrorCode::OPERATION_IN_PROGRESS)
|
||||
{
|
||||
this->waitForDevice();
|
||||
}
|
||||
|
@ -16,10 +16,8 @@
|
||||
* along with openauto. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <f1x/aasdk/Messenger/MessageInStream.hpp>
|
||||
#include <f1x/aasdk/Messenger/MessageOutStream.hpp>
|
||||
#include <f1x/aasdk/Messenger/Messenger.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/AndroidAutoEntity.hpp>
|
||||
#include <f1x/aasdk/Channel/Control/ControlServiceChannel.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/AndroidAutoEntity.hpp>
|
||||
#include <f1x/openauto/Common/Log.hpp>
|
||||
|
||||
namespace f1x
|
||||
@ -28,23 +26,24 @@ namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace projection
|
||||
namespace service
|
||||
{
|
||||
|
||||
AndroidAutoEntity::AndroidAutoEntity(boost::asio::io_service& ioService,
|
||||
aasdk::messenger::ICryptor::Pointer cryptor,
|
||||
aasdk::transport::ITransport::Pointer transport,
|
||||
aasdk::messenger::IMessenger::Pointer messenger,
|
||||
configuration::IConfiguration::Pointer configuration,
|
||||
IServiceFactory& serviceFactory)
|
||||
ServiceList serviceList,
|
||||
IPinger::Pointer pinger)
|
||||
: strand_(ioService)
|
||||
, cryptor_(std::move(cryptor))
|
||||
, transport_(std::move(transport))
|
||||
, configuration_(std::move(configuration))
|
||||
, 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_)))
|
||||
, messenger_(std::move(messenger))
|
||||
, controlServiceChannel_(std::make_shared<aasdk::channel::control::ControlServiceChannel>(strand_, messenger_))
|
||||
, configuration_(std::move(configuration))
|
||||
, serviceList_(std::move(serviceList))
|
||||
, pinger_(std::move(pinger))
|
||||
, eventHandler_(nullptr)
|
||||
{
|
||||
}
|
||||
@ -58,17 +57,15 @@ void AndroidAutoEntity::start(IAndroidAutoEntityEventHandler& eventHandler)
|
||||
{
|
||||
strand_.dispatch([this, self = this->shared_from_this(), eventHandler = &eventHandler]() {
|
||||
OPENAUTO_LOG(info) << "[AndroidAutoEntity] start.";
|
||||
|
||||
eventHandler_ = eventHandler;
|
||||
|
||||
cryptor_->init();
|
||||
|
||||
serviceList_ = serviceFactory_.create(messenger_);
|
||||
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_);
|
||||
versionRequestPromise->then([]() {}, std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
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()]() {
|
||||
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;
|
||||
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;
|
||||
auto promise = aasdk::channel::SendPromise::defer(strand_);
|
||||
promise->then([this, self = this->shared_from_this()]() {
|
||||
this->triggerQuit();
|
||||
},
|
||||
std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
promise->then(std::bind(&AndroidAutoEntity::triggerQuit, this->shared_from_this()),
|
||||
std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||
|
||||
controlServiceChannel_->sendShutdownResponse(response, std::move(promise));
|
||||
controlServiceChannel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
void AndroidAutoEntity::onPingResponse(const aasdk::proto::messages::PingResponse&)
|
||||
{
|
||||
pinger_->pong();
|
||||
controlServiceChannel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void AndroidAutoEntity::onChannelError(const aasdk::error::Error& e)
|
||||
{
|
||||
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/TCPTransport.hpp>
|
||||
#include <f1x/aasdk/Messenger/Cryptor.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/AndroidAutoEntityFactory.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/AndroidAutoEntity.hpp>
|
||||
#include <f1x/aasdk/Messenger/MessageInStream.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
|
||||
{
|
||||
@ -30,7 +34,7 @@ namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace projection
|
||||
namespace service
|
||||
{
|
||||
|
||||
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 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 <f1x/openauto/Common/Log.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/AudioInputService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/AudioInputService.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
@ -26,10 +26,10 @@ namespace openauto
|
||||
{
|
||||
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)
|
||||
, channel_(std::make_shared<aasdk::channel::av::AVInputServiceChannel>(strand_, std::move(messenger)))
|
||||
, audioInput_(std::move(audioInput))
|
||||
@ -114,7 +114,7 @@ void AudioInputService::onAVInputOpenRequest(const aasdk::proto::messages::AVInp
|
||||
|
||||
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()),
|
||||
[this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(error) << "[AudioInputService] audio input open failed.";
|
||||
@ -185,7 +185,7 @@ void AudioInputService::readAudioInput()
|
||||
{
|
||||
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),
|
||||
[this, self = this->shared_from_this()]() {
|
||||
OPENAUTO_LOG(info) << "[AudioInputService] audio input read rejected.";
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
#include <f1x/openauto/Common/Log.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/AudioService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/AudioService.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
@ -25,10 +25,10 @@ namespace openauto
|
||||
{
|
||||
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)
|
||||
, channel_(std::move(channel))
|
||||
, audioOutput_(std::move(audioOutput))
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
#include <f1x/openauto/Common/Log.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/BluetoothService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/BluetoothService.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
@ -25,10 +25,10 @@ namespace openauto
|
||||
{
|
||||
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)
|
||||
, channel_(std::make_shared<aasdk::channel::bluetooth::BluetoothServiceChannel>(strand_, std::move(messenger)))
|
||||
, bluetoothDevice_(std::move(bluetoothDevice))
|
@ -18,7 +18,7 @@
|
||||
|
||||
#include <aasdk_proto/InputEventIndicationMessage.pb.h>
|
||||
#include <f1x/openauto/Common/Log.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/InputService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/InputService.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
@ -26,10 +26,10 @@ namespace openauto
|
||||
{
|
||||
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)
|
||||
, channel_(std::make_shared<aasdk::channel::input::InputServiceChannel>(strand_, std::move(messenger)))
|
||||
, inputDevice_(std::move(inputDevice))
|
||||
@ -135,7 +135,7 @@ void InputService::onChannelError(const aasdk::error::Error& e)
|
||||
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());
|
||||
|
||||
@ -146,14 +146,14 @@ void InputService::onButtonEvent(const ButtonEvent& event)
|
||||
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 == WheelDirection::LEFT ? -1 : 1);
|
||||
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 == ButtonEventType::PRESS);
|
||||
buttonEvent->set_is_pressed(event.type == projection::ButtonEventType::PRESS);
|
||||
buttonEvent->set_long_press(false);
|
||||
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());
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
#include <f1x/aasdk/Channel/AV/MediaAudioServiceChannel.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/MediaAudioService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/MediaAudioService.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
@ -25,10 +25,10 @@ namespace openauto
|
||||
{
|
||||
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))
|
||||
{
|
||||
|
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 <f1x/openauto/Common/Log.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/SensorService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/SensorService.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
@ -26,7 +26,7 @@ namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace projection
|
||||
namespace service
|
||||
{
|
||||
|
||||
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/SystemAudioServiceChannel.hpp>
|
||||
#include <f1x/aasdk/Channel/AV/SpeechAudioServiceChannel.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/ServiceFactory.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/VideoService.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/MediaAudioService.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/SpeechAudioService.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/SystemAudioService.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/AudioInputService.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/SensorService.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/BluetoothService.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/InputService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/ServiceFactory.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/VideoService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/MediaAudioService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/SpeechAudioService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/SystemAudioService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/AudioInputService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/SensorService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/BluetoothService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/InputService.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/QtVideoOutput.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/OMXVideoOutput.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/RtAudioOutput.hpp>
|
||||
@ -46,7 +46,7 @@ namespace openauto
|
||||
{
|
||||
namespace autoapp
|
||||
{
|
||||
namespace projection
|
||||
namespace service
|
||||
{
|
||||
|
||||
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;
|
||||
|
||||
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)));
|
||||
this->createAudioServices(serviceList, 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)
|
||||
{
|
||||
#ifdef USE_OMX
|
||||
IVideoOutput::Pointer videoOutput(std::make_shared<OMXVideoOutput>(configuration_));
|
||||
auto videoOutput(std::make_shared<projection::OMXVideoOutput>(configuration_));
|
||||
#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
|
||||
return std::make_shared<VideoService>(ioService_, messenger, std::move(videoOutput));
|
||||
}
|
||||
|
||||
IService::Pointer ServiceFactory::createBluetoothService(aasdk::messenger::IMessenger::Pointer messenger)
|
||||
{
|
||||
IBluetoothDevice::Pointer bluetoothDevice;
|
||||
projection::IBluetoothDevice::Pointer bluetoothDevice;
|
||||
switch(configuration_->getBluetoothAdapterType())
|
||||
{
|
||||
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;
|
||||
|
||||
case configuration::BluetoothAdapterType::REMOTE:
|
||||
bluetoothDevice = std::make_shared<RemoteBluetoothDevice>(configuration_->getBluetoothRemoteAdapterAddress());
|
||||
bluetoothDevice = std::make_shared<projection::RemoteBluetoothDevice>(configuration_->getBluetoothRemoteAdapterAddress());
|
||||
break;
|
||||
|
||||
default:
|
||||
bluetoothDevice = std::make_shared<DummyBluetoothDevice>();
|
||||
bluetoothDevice = std::make_shared<projection::DummyBluetoothDevice>();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ IService::Pointer ServiceFactory::createInputService(aasdk::messenger::IMessenge
|
||||
|
||||
QScreen* screen = QGuiApplication::primaryScreen();
|
||||
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));
|
||||
}
|
||||
@ -132,8 +132,8 @@ void ServiceFactory::createAudioServices(ServiceList& serviceList, aasdk::messen
|
||||
if(configuration_->musicAudioChannelEnabled())
|
||||
{
|
||||
auto mediaAudioOutput = configuration_->getAudioOutputBackendType() == configuration::AudioOutputBackendType::RTAUDIO ?
|
||||
std::make_shared<RtAudioOutput>(2, 16, 48000) :
|
||||
IAudioOutput::Pointer(new QtAudioOutput(2, 16, 48000), std::bind(&QObject::deleteLater, std::placeholders::_1));
|
||||
std::make_shared<projection::RtAudioOutput>(2, 16, 48000) :
|
||||
projection::IAudioOutput::Pointer(new projection::QtAudioOutput(2, 16, 48000), std::bind(&QObject::deleteLater, std::placeholders::_1));
|
||||
|
||||
serviceList.emplace_back(std::make_shared<MediaAudioService>(ioService_, messenger, std::move(mediaAudioOutput)));
|
||||
}
|
||||
@ -141,15 +141,15 @@ void ServiceFactory::createAudioServices(ServiceList& serviceList, aasdk::messen
|
||||
if(configuration_->speechAudioChannelEnabled())
|
||||
{
|
||||
auto speechAudioOutput = configuration_->getAudioOutputBackendType() == configuration::AudioOutputBackendType::RTAUDIO ?
|
||||
std::make_shared<RtAudioOutput>(1, 16, 16000) :
|
||||
IAudioOutput::Pointer(new QtAudioOutput(1, 16, 16000), std::bind(&QObject::deleteLater, std::placeholders::_1));
|
||||
std::make_shared<projection::RtAudioOutput>(1, 16, 16000) :
|
||||
projection::IAudioOutput::Pointer(new projection::QtAudioOutput(1, 16, 16000), std::bind(&QObject::deleteLater, std::placeholders::_1));
|
||||
|
||||
serviceList.emplace_back(std::make_shared<SpeechAudioService>(ioService_, messenger, std::move(speechAudioOutput)));
|
||||
}
|
||||
|
||||
auto systemAudioOutput = configuration_->getAudioOutputBackendType() == configuration::AudioOutputBackendType::RTAUDIO ?
|
||||
std::make_shared<RtAudioOutput>(1, 16, 16000) :
|
||||
IAudioOutput::Pointer(new QtAudioOutput(1, 16, 16000), std::bind(&QObject::deleteLater, std::placeholders::_1));
|
||||
std::make_shared<projection::RtAudioOutput>(1, 16, 16000) :
|
||||
projection::IAudioOutput::Pointer(new projection::QtAudioOutput(1, 16, 16000), std::bind(&QObject::deleteLater, std::placeholders::_1));
|
||||
|
||||
serviceList.emplace_back(std::make_shared<SystemAudioService>(ioService_, messenger, std::move(systemAudioOutput)));
|
||||
}
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
#include <f1x/aasdk/Channel/AV/SpeechAudioServiceChannel.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/SpeechAudioService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/SpeechAudioService.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
@ -25,10 +25,10 @@ namespace openauto
|
||||
{
|
||||
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))
|
||||
{
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
#include <f1x/aasdk/Channel/AV/SystemAudioServiceChannel.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/SystemAudioService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/SystemAudioService.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
@ -25,10 +25,10 @@ namespace openauto
|
||||
{
|
||||
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))
|
||||
{
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
#include <f1x/openauto/Common/Log.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/VideoService.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/VideoService.hpp>
|
||||
|
||||
namespace f1x
|
||||
{
|
||||
@ -25,10 +25,10 @@ namespace openauto
|
||||
{
|
||||
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)
|
||||
, channel_(std::make_shared<aasdk::channel::av::VideoServiceChannel>(strand_, std::move(messenger)))
|
||||
, videoOutput_(std::move(videoOutput))
|
@ -27,8 +27,8 @@
|
||||
#include <f1x/openauto/autoapp/App.hpp>
|
||||
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
||||
#include <f1x/openauto/autoapp/Configuration/RecentAddressesList.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/AndroidAutoEntityFactory.hpp>
|
||||
#include <f1x/openauto/autoapp/Projection/ServiceFactory.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/AndroidAutoEntityFactory.hpp>
|
||||
#include <f1x/openauto/autoapp/Service/ServiceFactory.hpp>
|
||||
#include <f1x/openauto/autoapp/Configuration/Configuration.hpp>
|
||||
#include <f1x/openauto/autoapp/UI/MainWindow.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::AccessoryModeQueryFactory queryFactory(usbWrapper, ioService);
|
||||
aasdk::usb::AccessoryModeQueryChainFactory queryChainFactory(usbWrapper, ioService, queryFactory);
|
||||
autoapp::projection::ServiceFactory serviceFactory(ioService, configuration);
|
||||
autoapp::projection::AndroidAutoEntityFactory androidAutoEntityFactory(ioService, configuration, serviceFactory);
|
||||
autoapp::service::ServiceFactory serviceFactory(ioService, configuration);
|
||||
autoapp::service::AndroidAutoEntityFactory androidAutoEntityFactory(ioService, configuration, serviceFactory);
|
||||
|
||||
auto usbHub(std::make_shared<aasdk::usb::USBHub>(usbWrapper, ioService, queryChainFactory));
|
||||
auto connectedAccessoriesEnumerator(std::make_shared<aasdk::usb::ConnectedAccessoriesEnumerator>(usbWrapper, ioService, queryChainFactory));
|
||||
|
Loading…
x
Reference in New Issue
Block a user