updates to make things work (stolen from other people); modifying interfaces for qt support
This commit is contained in:
parent
7513d99929
commit
ae5a21a75e
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,4 +1,6 @@
|
|||||||
# Add any directories, files, or patterns you don't want to be tracked by version control
|
# Add any directories, files, or patterns you don't want to be tracked by version control
|
||||||
|
.vscode/
|
||||||
|
|
||||||
lib/
|
lib/
|
||||||
bin/
|
bin/
|
||||||
CMakeLists.txt.user
|
CMakeLists.txt.user
|
||||||
|
@ -38,13 +38,13 @@ if(WIN32)
|
|||||||
set(WINSOCK2_LIBRARIES "ws2_32")
|
set(WINSOCK2_LIBRARIES "ws2_32")
|
||||||
endif(WIN32)
|
endif(WIN32)
|
||||||
|
|
||||||
if(RPI3_BUILD)
|
if(RPI_BUILD)
|
||||||
add_definitions(-DUSE_OMX -DOMX_SKIP64BIT -DRASPBERRYPI3)
|
add_definitions(-DUSE_OMX -DOMX_SKIP64BIT)
|
||||||
set(BCM_HOST_LIBRARIES "/opt/vc/lib/libbcm_host.so")
|
set(BCM_HOST_LIBRARIES "/opt/vc/lib/libbcm_host.so")
|
||||||
set(BCM_HOST_INCLUDE_DIRS "/opt/vc/include")
|
set(BCM_HOST_INCLUDE_DIRS "/opt/vc/include")
|
||||||
set(ILCLIENT_INCLUDE_DIRS "/opt/vc/src/hello_pi/libs/ilclient")
|
set(ILCLIENT_INCLUDE_DIRS "/opt/vc/src/hello_pi/libs/ilclient")
|
||||||
set(ILCLIENT_LIBRARIES "/opt/vc/src/hello_pi/libs/ilclient/libilclient.a;/opt/vc/lib/libvcos.so;/opt/vc/lib/libvcilcs.a;/opt/vc/lib/libvchiq_arm.so")
|
set(ILCLIENT_LIBRARIES "/opt/vc/src/hello_pi/libs/ilclient/libilclient.a;/opt/vc/lib/libvcos.so;/opt/vc/lib/libvcilcs.a;/opt/vc/lib/libvchiq_arm.so")
|
||||||
endif(RPI3_BUILD)
|
endif(RPI_BUILD)
|
||||||
|
|
||||||
include_directories(${CMAKE_CURRENT_BINARY_DIR}
|
include_directories(${CMAKE_CURRENT_BINARY_DIR}
|
||||||
${Qt5Multimedia_INCLUDE_DIRS}
|
${Qt5Multimedia_INCLUDE_DIRS}
|
||||||
@ -72,6 +72,10 @@ file(GLOB_RECURSE autoapp_source_files ${autoapp_sources_directory}/*.ui ${autoa
|
|||||||
|
|
||||||
add_executable(autoapp ${autoapp_source_files})
|
add_executable(autoapp ${autoapp_source_files})
|
||||||
|
|
||||||
|
file(GLOB_RECURSE autoapp_lib_source_files ${autoapp_sources_directory}/App.cpp ${autoapp_sources_directory}/Configuration/*.cpp ${autoapp_sources_directory}/Projection/*.cpp ${autoapp_sources_directory}/Service/*.cpp)
|
||||||
|
file(GLOB_RECURSE autoapp_lib_inlcude_files ${autoapp_include_directory}/App.hpp ${autoapp_include_directory}/Configuration/*.hpp ${autoapp_include_directory}/Projection/*.hpp ${autoapp_include_directory}/Service/*.hpp)
|
||||||
|
add_library(auto SHARED ${autoapp_lib_source_files} ${autoapp_lib_inlcude_files})
|
||||||
|
|
||||||
target_link_libraries(autoapp
|
target_link_libraries(autoapp
|
||||||
${Boost_LIBRARIES}
|
${Boost_LIBRARIES}
|
||||||
${Qt5Multimedia_LIBRARIES}
|
${Qt5Multimedia_LIBRARIES}
|
||||||
|
@ -26,6 +26,7 @@ extern "C"
|
|||||||
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
|
#include <functional>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <boost/circular_buffer.hpp>
|
#include <boost/circular_buffer.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/VideoOutput.hpp>
|
#include <f1x/openauto/autoapp/Projection/VideoOutput.hpp>
|
||||||
@ -39,15 +40,28 @@ namespace autoapp
|
|||||||
namespace projection
|
namespace projection
|
||||||
{
|
{
|
||||||
|
|
||||||
|
struct DestRect
|
||||||
|
{
|
||||||
|
DestRect();
|
||||||
|
DestRect(OMX_S16 xOffset, OMX_S16 yOffset, OMX_S16 width, OMX_S16 height);
|
||||||
|
|
||||||
|
OMX_BOOL fullscreen;
|
||||||
|
OMX_S16 xOffset;
|
||||||
|
OMX_S16 yOffset;
|
||||||
|
OMX_S16 width;
|
||||||
|
OMX_S16 height;
|
||||||
|
};
|
||||||
|
|
||||||
class OMXVideoOutput: public VideoOutput
|
class OMXVideoOutput: public VideoOutput
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
OMXVideoOutput(configuration::IConfiguration::Pointer configuration);
|
OMXVideoOutput(configuration::IConfiguration::Pointer configuration, DestRect destRect=DestRect(), std::function<void(bool)> activeCallback=nullptr);
|
||||||
|
|
||||||
bool open() override;
|
bool open() override;
|
||||||
bool init() override;
|
bool init() override;
|
||||||
void write(uint64_t timestamp, const aasdk::common::DataConstBuffer& buffer) override;
|
void write(uint64_t timestamp, const aasdk::common::DataConstBuffer& buffer) override;
|
||||||
void stop() override;
|
void stop() override;
|
||||||
|
void setOpacity(OMX_U32 alpha);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool createComponents();
|
bool createComponents();
|
||||||
@ -62,6 +76,9 @@ private:
|
|||||||
ILCLIENT_T* client_;
|
ILCLIENT_T* client_;
|
||||||
COMPONENT_T* components_[5];
|
COMPONENT_T* components_[5];
|
||||||
TUNNEL_T tunnels_[4];
|
TUNNEL_T tunnels_[4];
|
||||||
|
DestRect destRect_;
|
||||||
|
OMX_U32 alpha_;
|
||||||
|
std::function<void(bool)> activeCallback_;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ class QtVideoOutput: public QObject, public VideoOutput, boost::noncopyable
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QtVideoOutput(configuration::IConfiguration::Pointer configuration);
|
QtVideoOutput(configuration::IConfiguration::Pointer configuration, QWidget* videoContainer=nullptr);
|
||||||
bool open() override;
|
bool open() override;
|
||||||
bool init() override;
|
bool init() override;
|
||||||
void write(uint64_t timestamp, const aasdk::common::DataConstBuffer& buffer) override;
|
void write(uint64_t timestamp, const aasdk::common::DataConstBuffer& buffer) override;
|
||||||
@ -57,6 +57,7 @@ private:
|
|||||||
SequentialBuffer videoBuffer_;
|
SequentialBuffer videoBuffer_;
|
||||||
std::unique_ptr<QVideoWidget> videoWidget_;
|
std::unique_ptr<QVideoWidget> videoWidget_;
|
||||||
std::unique_ptr<QMediaPlayer> mediaPlayer_;
|
std::unique_ptr<QMediaPlayer> mediaPlayer_;
|
||||||
|
QWidget* videoContainer_;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include <f1x/openauto/autoapp/Service/IServiceFactory.hpp>
|
#include <f1x/openauto/autoapp/Service/IServiceFactory.hpp>
|
||||||
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
#include <f1x/openauto/autoapp/Configuration/IConfiguration.hpp>
|
||||||
|
#include <f1x/openauto/autoapp/Projection/OMXVideoOutput.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
{
|
{
|
||||||
@ -33,8 +34,13 @@ namespace service
|
|||||||
class ServiceFactory: public IServiceFactory
|
class ServiceFactory: public IServiceFactory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ServiceFactory(boost::asio::io_service& ioService, configuration::IConfiguration::Pointer configuration);
|
ServiceFactory(boost::asio::io_service& ioService, configuration::IConfiguration::Pointer configuration, QWidget* activeArea=nullptr, std::function<void(bool)> activeCallback=nullptr);
|
||||||
ServiceList create(aasdk::messenger::IMessenger::Pointer messenger) override;
|
ServiceList create(aasdk::messenger::IMessenger::Pointer messenger) override;
|
||||||
|
void setOpacity(unsigned int alpha);
|
||||||
|
static QRect mapActiveAreaToGlobal(QWidget* activeArea);
|
||||||
|
#ifdef USE_OMX
|
||||||
|
static projection::DestRect QRectToDestRect(QRect rect);
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IService::Pointer createVideoService(aasdk::messenger::IMessenger::Pointer messenger);
|
IService::Pointer createVideoService(aasdk::messenger::IMessenger::Pointer messenger);
|
||||||
@ -44,6 +50,12 @@ private:
|
|||||||
|
|
||||||
boost::asio::io_service& ioService_;
|
boost::asio::io_service& ioService_;
|
||||||
configuration::IConfiguration::Pointer configuration_;
|
configuration::IConfiguration::Pointer configuration_;
|
||||||
|
QWidget* activeArea_;
|
||||||
|
QRect screenGeometry_;
|
||||||
|
std::function<void(bool)> activeCallback_;
|
||||||
|
#ifdef USE_OMX
|
||||||
|
std::shared_ptr<projection::OMXVideoOutput> omxVideoOutput_;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,7 @@ public:
|
|||||||
void onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request) override;
|
void onChannelOpenRequest(const aasdk::proto::messages::ChannelOpenRequest& request) override;
|
||||||
void onAVChannelSetupRequest(const aasdk::proto::messages::AVChannelSetupRequest& request) override;
|
void onAVChannelSetupRequest(const aasdk::proto::messages::AVChannelSetupRequest& request) override;
|
||||||
void onAVChannelStartIndication(const aasdk::proto::messages::AVChannelStartIndication& indication) override;
|
void onAVChannelStartIndication(const aasdk::proto::messages::AVChannelStartIndication& indication) override;
|
||||||
|
void onAVChannelStopIndication(const aasdk::proto::messages::AVChannelStopIndication& indication) override;
|
||||||
void onAVMediaWithTimestampIndication(aasdk::messenger::Timestamp::ValueType timestamp, const aasdk::common::DataConstBuffer& buffer) override;
|
void onAVMediaWithTimestampIndication(aasdk::messenger::Timestamp::ValueType timestamp, const aasdk::common::DataConstBuffer& buffer) override;
|
||||||
void onAVMediaIndication(const aasdk::common::DataConstBuffer& buffer) override;
|
void onAVMediaIndication(const aasdk::common::DataConstBuffer& buffer) override;
|
||||||
void onVideoFocusRequest(const aasdk::proto::messages::VideoFocusRequest& request) override;
|
void onVideoFocusRequest(const aasdk::proto::messages::VideoFocusRequest& request) override;
|
||||||
|
@ -36,6 +36,22 @@ namespace autoapp
|
|||||||
namespace projection
|
namespace projection
|
||||||
{
|
{
|
||||||
|
|
||||||
|
DestRect::DestRect()
|
||||||
|
: fullscreen(OMX_TRUE)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
DestRect::DestRect(OMX_S16 _xOffset, OMX_S16 _yOffset, OMX_S16 _width, OMX_S16 _height)
|
||||||
|
: fullscreen(OMX_FALSE)
|
||||||
|
, xOffset(_xOffset)
|
||||||
|
, yOffset(_yOffset)
|
||||||
|
, width(_width)
|
||||||
|
, height(_height)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
namespace VideoComponent
|
namespace VideoComponent
|
||||||
{
|
{
|
||||||
static constexpr uint32_t DECODER = 0;
|
static constexpr uint32_t DECODER = 0;
|
||||||
@ -44,11 +60,14 @@ namespace VideoComponent
|
|||||||
static constexpr uint32_t SCHEDULER = 3;
|
static constexpr uint32_t SCHEDULER = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
OMXVideoOutput::OMXVideoOutput(configuration::IConfiguration::Pointer configuration)
|
OMXVideoOutput::OMXVideoOutput(configuration::IConfiguration::Pointer configuration, DestRect destRect, std::function<void(bool)> activeCallback)
|
||||||
: VideoOutput(std::move(configuration))
|
: VideoOutput(std::move(configuration))
|
||||||
, isActive_(false)
|
, isActive_(false)
|
||||||
, portSettingsChanged_(false)
|
, portSettingsChanged_(false)
|
||||||
, client_(nullptr)
|
, client_(nullptr)
|
||||||
|
, destRect_(destRect)
|
||||||
|
, alpha_(255)
|
||||||
|
, activeCallback_(activeCallback)
|
||||||
{
|
{
|
||||||
memset(components_, 0, sizeof(components_));
|
memset(components_, 0, sizeof(components_));
|
||||||
memset(tunnels_, 0, sizeof(tunnels_));
|
memset(tunnels_, 0, sizeof(tunnels_));
|
||||||
@ -95,6 +114,10 @@ bool OMXVideoOutput::open()
|
|||||||
}
|
}
|
||||||
|
|
||||||
isActive_ = true;
|
isActive_ = true;
|
||||||
|
if(this->activeCallback_ != nullptr)
|
||||||
|
{
|
||||||
|
this->activeCallback_(isActive_);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,10 +138,20 @@ bool OMXVideoOutput::setupDisplayRegion()
|
|||||||
displayRegion.nVersion.nVersion = OMX_VERSION;
|
displayRegion.nVersion.nVersion = OMX_VERSION;
|
||||||
displayRegion.nPortIndex = 90;
|
displayRegion.nPortIndex = 90;
|
||||||
displayRegion.layer = static_cast<OMX_S32>(configuration_->getOMXLayerIndex());
|
displayRegion.layer = static_cast<OMX_S32>(configuration_->getOMXLayerIndex());
|
||||||
displayRegion.fullscreen = OMX_TRUE;
|
displayRegion.fullscreen = destRect_.fullscreen;
|
||||||
displayRegion.noaspect = OMX_TRUE;
|
displayRegion.noaspect = OMX_TRUE;
|
||||||
displayRegion.set = static_cast<OMX_DISPLAYSETTYPE >(OMX_DISPLAY_SET_FULLSCREEN | OMX_DISPLAY_SET_NOASPECT | OMX_DISPLAY_SET_LAYER);
|
displayRegion.set = static_cast<OMX_DISPLAYSETTYPE >(OMX_DISPLAY_SET_FULLSCREEN | OMX_DISPLAY_SET_NOASPECT | OMX_DISPLAY_SET_LAYER);
|
||||||
|
|
||||||
|
if (destRect_.fullscreen == OMX_FALSE)
|
||||||
|
{
|
||||||
|
displayRegion.alpha = alpha_;
|
||||||
|
displayRegion.dest_rect.x_offset = destRect_.xOffset;
|
||||||
|
displayRegion.dest_rect.y_offset = destRect_.yOffset;
|
||||||
|
displayRegion.dest_rect.width = destRect_.width;
|
||||||
|
displayRegion.dest_rect.height = destRect_.height;
|
||||||
|
displayRegion.set = static_cast<OMX_DISPLAYSETTYPE >(displayRegion.set | OMX_DISPLAY_SET_ALPHA | OMX_DISPLAY_SET_DEST_RECT);
|
||||||
|
}
|
||||||
|
|
||||||
return OMX_SetConfig(ilclient_get_handle(components_[VideoComponent::RENDERER]), OMX_IndexConfigDisplayRegion, &displayRegion) == OMX_ErrorNone;
|
return OMX_SetConfig(ilclient_get_handle(components_[VideoComponent::RENDERER]), OMX_IndexConfigDisplayRegion, &displayRegion) == OMX_ErrorNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,6 +219,10 @@ void OMXVideoOutput::stop()
|
|||||||
if(isActive_)
|
if(isActive_)
|
||||||
{
|
{
|
||||||
isActive_ = false;
|
isActive_ = false;
|
||||||
|
if(this->activeCallback_ != nullptr)
|
||||||
|
{
|
||||||
|
this->activeCallback_(isActive_);
|
||||||
|
}
|
||||||
|
|
||||||
ilclient_disable_tunnel(&tunnels_[0]);
|
ilclient_disable_tunnel(&tunnels_[0]);
|
||||||
ilclient_disable_tunnel(&tunnels_[1]);
|
ilclient_disable_tunnel(&tunnels_[1]);
|
||||||
@ -199,6 +236,27 @@ void OMXVideoOutput::stop()
|
|||||||
ilclient_cleanup_components(components_);
|
ilclient_cleanup_components(components_);
|
||||||
OMX_Deinit();
|
OMX_Deinit();
|
||||||
ilclient_destroy(client_);
|
ilclient_destroy(client_);
|
||||||
|
client_ = nullptr;
|
||||||
|
|
||||||
|
portSettingsChanged_ = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OMXVideoOutput::setOpacity(OMX_U32 alpha)
|
||||||
|
{
|
||||||
|
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||||
|
|
||||||
|
alpha_ = alpha;
|
||||||
|
if(isActive_)
|
||||||
|
{
|
||||||
|
OMX_CONFIG_DISPLAYREGIONTYPE displayRegion;
|
||||||
|
displayRegion.nSize = sizeof(OMX_CONFIG_DISPLAYREGIONTYPE);
|
||||||
|
displayRegion.nVersion.nVersion = OMX_VERSION;
|
||||||
|
displayRegion.nPortIndex = 90;
|
||||||
|
displayRegion.alpha = alpha_;
|
||||||
|
displayRegion.set = static_cast<OMX_DISPLAYSETTYPE >(OMX_DISPLAY_SET_ALPHA);
|
||||||
|
|
||||||
|
OMX_SetConfig(ilclient_get_handle(components_[VideoComponent::RENDERER]), OMX_IndexConfigDisplayRegion, &displayRegion) == OMX_ErrorNone;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,8 +29,9 @@ namespace autoapp
|
|||||||
namespace projection
|
namespace projection
|
||||||
{
|
{
|
||||||
|
|
||||||
QtVideoOutput::QtVideoOutput(configuration::IConfiguration::Pointer configuration)
|
QtVideoOutput::QtVideoOutput(configuration::IConfiguration::Pointer configuration, QWidget* videoContainer)
|
||||||
: VideoOutput(std::move(configuration))
|
: VideoOutput(std::move(configuration))
|
||||||
|
, videoContainer_(videoContainer)
|
||||||
{
|
{
|
||||||
this->moveToThread(QApplication::instance()->thread());
|
this->moveToThread(QApplication::instance()->thread());
|
||||||
connect(this, &QtVideoOutput::startPlayback, this, &QtVideoOutput::onStartPlayback, Qt::QueuedConnection);
|
connect(this, &QtVideoOutput::startPlayback, this, &QtVideoOutput::onStartPlayback, Qt::QueuedConnection);
|
||||||
@ -42,7 +43,7 @@ QtVideoOutput::QtVideoOutput(configuration::IConfiguration::Pointer configuratio
|
|||||||
void QtVideoOutput::createVideoOutput()
|
void QtVideoOutput::createVideoOutput()
|
||||||
{
|
{
|
||||||
OPENAUTO_LOG(debug) << "[QtVideoOutput] create.";
|
OPENAUTO_LOG(debug) << "[QtVideoOutput] create.";
|
||||||
videoWidget_ = std::make_unique<QVideoWidget>();
|
videoWidget_ = std::make_unique<QVideoWidget>(videoContainer_);
|
||||||
mediaPlayer_ = std::make_unique<QMediaPlayer>(nullptr, QMediaPlayer::StreamPlayback);
|
mediaPlayer_ = std::make_unique<QMediaPlayer>(nullptr, QMediaPlayer::StreamPlayback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,10 +71,17 @@ void QtVideoOutput::write(uint64_t, const aasdk::common::DataConstBuffer& buffer
|
|||||||
|
|
||||||
void QtVideoOutput::onStartPlayback()
|
void QtVideoOutput::onStartPlayback()
|
||||||
{
|
{
|
||||||
videoWidget_->setAspectRatioMode(Qt::IgnoreAspectRatio);
|
if (videoContainer_ == nullptr)
|
||||||
videoWidget_->setFocus();
|
{
|
||||||
videoWidget_->setWindowFlags(Qt::WindowStaysOnTopHint);
|
videoWidget_->setAspectRatioMode(Qt::IgnoreAspectRatio);
|
||||||
videoWidget_->setFullScreen(true);
|
videoWidget_->setFocus();
|
||||||
|
videoWidget_->setWindowFlags(Qt::WindowStaysOnTopHint);
|
||||||
|
videoWidget_->setFullScreen(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
videoWidget_->resize(videoContainer_->size());
|
||||||
|
}
|
||||||
videoWidget_->show();
|
videoWidget_->show();
|
||||||
|
|
||||||
mediaPlayer_->setVideoOutput(videoWidget_.get());
|
mediaPlayer_->setVideoOutput(videoWidget_.get());
|
||||||
|
@ -272,6 +272,8 @@ void AndroidAutoEntity::sendPing()
|
|||||||
promise->then([]() {}, std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
promise->then([]() {}, std::bind(&AndroidAutoEntity::onChannelError, this->shared_from_this(), std::placeholders::_1));
|
||||||
|
|
||||||
aasdk::proto::messages::PingRequest request;
|
aasdk::proto::messages::PingRequest request;
|
||||||
|
auto timestamp = std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now().time_since_epoch());
|
||||||
|
request.set_timestamp(timestamp.count());
|
||||||
controlServiceChannel_->sendPingRequest(request, std::move(promise));
|
controlServiceChannel_->sendPingRequest(request, std::move(promise));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,9 +49,15 @@ namespace autoapp
|
|||||||
namespace service
|
namespace service
|
||||||
{
|
{
|
||||||
|
|
||||||
ServiceFactory::ServiceFactory(boost::asio::io_service& ioService, configuration::IConfiguration::Pointer configuration)
|
ServiceFactory::ServiceFactory(boost::asio::io_service& ioService, configuration::IConfiguration::Pointer configuration, QWidget *activeArea, std::function<void(bool)> activeCallback)
|
||||||
: ioService_(ioService)
|
: ioService_(ioService)
|
||||||
, configuration_(std::move(configuration))
|
, configuration_(std::move(configuration))
|
||||||
|
, activeArea_(activeArea)
|
||||||
|
, screenGeometry_(this->mapActiveAreaToGlobal(activeArea_))
|
||||||
|
, activeCallback_(activeCallback)
|
||||||
|
#ifdef USE_OMX
|
||||||
|
, omxVideoOutput_(std::make_shared<projection::OMXVideoOutput>(configuration_, this->QRectToDestRect(screenGeometry_), activeCallback_))
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -74,9 +80,10 @@ 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
|
||||||
auto videoOutput(std::make_shared<projection::OMXVideoOutput>(configuration_));
|
auto videoOutput(omxVideoOutput_);
|
||||||
#else
|
#else
|
||||||
projection::IVideoOutput::Pointer videoOutput(new projection::QtVideoOutput(configuration_), std::bind(&QObject::deleteLater, std::placeholders::_1));
|
auto qtVideoOutput = new projection::QtVideoOutput(configuration_, activeArea_);
|
||||||
|
projection::IVideoOutput::Pointer videoOutput(qtVideoOutput, 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));
|
||||||
}
|
}
|
||||||
@ -120,9 +127,8 @@ IService::Pointer ServiceFactory::createInputService(aasdk::messenger::IMessenge
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
QScreen* screen = QGuiApplication::primaryScreen();
|
QObject* inputObject = activeArea_ == nullptr ? qobject_cast<QObject*>(QApplication::instance()) : qobject_cast<QObject*>(activeArea_);
|
||||||
QRect screenGeometry = screen == nullptr ? QRect(0, 0, 1, 1) : screen->geometry();
|
projection::IInputDevice::Pointer inputDevice(std::make_shared<projection::InputDevice>(*inputObject, 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));
|
||||||
}
|
}
|
||||||
@ -154,6 +160,34 @@ void ServiceFactory::createAudioServices(ServiceList& serviceList, aasdk::messen
|
|||||||
serviceList.emplace_back(std::make_shared<SystemAudioService>(ioService_, messenger, std::move(systemAudioOutput)));
|
serviceList.emplace_back(std::make_shared<SystemAudioService>(ioService_, messenger, std::move(systemAudioOutput)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ServiceFactory::setOpacity(unsigned int alpha)
|
||||||
|
{
|
||||||
|
#ifdef USE_OMX
|
||||||
|
omxVideoOutput_->setOpacity(alpha);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
QRect ServiceFactory::mapActiveAreaToGlobal(QWidget* activeArea)
|
||||||
|
{
|
||||||
|
if (activeArea == nullptr)
|
||||||
|
{
|
||||||
|
QScreen* screen = QGuiApplication::primaryScreen();
|
||||||
|
return screen == nullptr ? QRect(0, 0, 1, 1) : screen->geometry();
|
||||||
|
}
|
||||||
|
|
||||||
|
QRect g = activeArea->geometry();
|
||||||
|
QPoint p = activeArea->mapToGlobal(g.topLeft());
|
||||||
|
|
||||||
|
return QRect(p.x(), p.y(), g.width(), g.height());
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef USE_OMX
|
||||||
|
projection::DestRect ServiceFactory::QRectToDestRect(QRect rect)
|
||||||
|
{
|
||||||
|
return projection::DestRect(rect.x(), rect.y(), rect.width(), rect.height());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,13 @@ void VideoService::onAVChannelStartIndication(const aasdk::proto::messages::AVCh
|
|||||||
channel_->receive(this->shared_from_this());
|
channel_->receive(this->shared_from_this());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VideoService::onAVChannelStopIndication(const aasdk::proto::messages::AVChannelStopIndication& indication)
|
||||||
|
{
|
||||||
|
OPENAUTO_LOG(info) << "[VideoService] stop indication";
|
||||||
|
|
||||||
|
channel_->receive(this->shared_from_this());
|
||||||
|
}
|
||||||
|
|
||||||
void VideoService::onAVMediaWithTimestampIndication(aasdk::messenger::Timestamp::ValueType timestamp, const aasdk::common::DataConstBuffer& buffer)
|
void VideoService::onAVMediaWithTimestampIndication(aasdk::messenger::Timestamp::ValueType timestamp, const aasdk::common::DataConstBuffer& buffer)
|
||||||
{
|
{
|
||||||
videoOutput_->write(timestamp, buffer);
|
videoOutput_->write(timestamp, buffer);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user