add interfaces to dynamically adjust video size (#1)
* adding interfaces for toggling fullscreen * passing in destrect to omx * adding flag for deffering video update * remove skipUpdate option for video output * fixing omx player stop deadlock; setting omx alpha in constructor * jk not setting opacity in constructor for omx * removing unsed function
This commit is contained in:
parent
5df4b957a1
commit
5f8d5f4f6a
@ -45,6 +45,7 @@ public:
|
|||||||
bool eventFilter(QObject* obj, QEvent* event) override;
|
bool eventFilter(QObject* obj, QEvent* event) override;
|
||||||
bool hasTouchscreen() const override;
|
bool hasTouchscreen() const override;
|
||||||
QRect getTouchscreenGeometry() const override;
|
QRect getTouchscreenGeometry() const override;
|
||||||
|
void setTouchscreenGeometry(QRect& touchscreenGeometry);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setVideoGeometry();
|
void setVideoGeometry();
|
||||||
|
@ -62,6 +62,7 @@ public:
|
|||||||
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);
|
void setOpacity(OMX_U32 alpha);
|
||||||
|
void setDestRect(DestRect destRect);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool createComponents();
|
bool createComponents();
|
||||||
|
@ -43,6 +43,7 @@ public:
|
|||||||
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 resize();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void startPlayback();
|
void startPlayback();
|
||||||
|
@ -20,7 +20,9 @@
|
|||||||
|
|
||||||
#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/InputDevice.hpp>
|
||||||
#include <f1x/openauto/autoapp/Projection/OMXVideoOutput.hpp>
|
#include <f1x/openauto/autoapp/Projection/OMXVideoOutput.hpp>
|
||||||
|
#include <f1x/openauto/autoapp/Projection/QtVideoOutput.hpp>
|
||||||
|
|
||||||
namespace f1x
|
namespace f1x
|
||||||
{
|
{
|
||||||
@ -37,6 +39,7 @@ public:
|
|||||||
ServiceFactory(boost::asio::io_service& ioService, configuration::IConfiguration::Pointer configuration, QWidget* activeArea=nullptr, std::function<void(bool)> activeCallback=nullptr);
|
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);
|
void setOpacity(unsigned int alpha);
|
||||||
|
void resize();
|
||||||
static QRect mapActiveAreaToGlobal(QWidget* activeArea);
|
static QRect mapActiveAreaToGlobal(QWidget* activeArea);
|
||||||
#ifdef USE_OMX
|
#ifdef USE_OMX
|
||||||
static projection::DestRect QRectToDestRect(QRect rect);
|
static projection::DestRect QRectToDestRect(QRect rect);
|
||||||
@ -53,8 +56,11 @@ private:
|
|||||||
QWidget* activeArea_;
|
QWidget* activeArea_;
|
||||||
QRect screenGeometry_;
|
QRect screenGeometry_;
|
||||||
std::function<void(bool)> activeCallback_;
|
std::function<void(bool)> activeCallback_;
|
||||||
|
std::shared_ptr<projection::InputDevice> inputDevice_;
|
||||||
#ifdef USE_OMX
|
#ifdef USE_OMX
|
||||||
std::shared_ptr<projection::OMXVideoOutput> omxVideoOutput_;
|
std::shared_ptr<projection::OMXVideoOutput> omxVideoOutput_;
|
||||||
|
#else
|
||||||
|
projection::QtVideoOutput *qtVideoOutput_;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -225,6 +225,11 @@ QRect InputDevice::getTouchscreenGeometry() const
|
|||||||
return touchscreenGeometry_;
|
return touchscreenGeometry_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InputDevice::setTouchscreenGeometry(QRect& touchscreenGeometry)
|
||||||
|
{
|
||||||
|
touchscreenGeometry_ = touchscreenGeometry;
|
||||||
|
}
|
||||||
|
|
||||||
IInputDevice::ButtonCodes InputDevice::getSupportedButtonCodes() const
|
IInputDevice::ButtonCodes InputDevice::getSupportedButtonCodes() const
|
||||||
{
|
{
|
||||||
return configuration_->getButtonCodes();
|
return configuration_->getButtonCodes();
|
||||||
|
@ -114,10 +114,12 @@ bool OMXVideoOutput::open()
|
|||||||
}
|
}
|
||||||
|
|
||||||
isActive_ = true;
|
isActive_ = true;
|
||||||
if(this->activeCallback_ != nullptr)
|
|
||||||
|
if(activeCallback_ != nullptr)
|
||||||
{
|
{
|
||||||
this->activeCallback_(isActive_);
|
activeCallback_(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,15 +216,16 @@ void OMXVideoOutput::stop()
|
|||||||
{
|
{
|
||||||
OPENAUTO_LOG(info) << "[OMXVideoOutput] stop.";
|
OPENAUTO_LOG(info) << "[OMXVideoOutput] stop.";
|
||||||
|
|
||||||
|
if(activeCallback_ != nullptr)
|
||||||
|
{
|
||||||
|
activeCallback_(false);
|
||||||
|
}
|
||||||
|
|
||||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||||
|
|
||||||
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]);
|
||||||
@ -249,14 +252,18 @@ void OMXVideoOutput::setOpacity(OMX_U32 alpha)
|
|||||||
alpha_ = alpha;
|
alpha_ = alpha;
|
||||||
if(isActive_)
|
if(isActive_)
|
||||||
{
|
{
|
||||||
OMX_CONFIG_DISPLAYREGIONTYPE displayRegion;
|
this->setupDisplayRegion();
|
||||||
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;
|
void OMXVideoOutput::setDestRect(DestRect destRect)
|
||||||
|
{
|
||||||
|
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||||
|
|
||||||
|
destRect_ = destRect;
|
||||||
|
if(isActive_)
|
||||||
|
{
|
||||||
|
this->setupDisplayRegion();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,6 +69,11 @@ void QtVideoOutput::write(uint64_t, const aasdk::common::DataConstBuffer& buffer
|
|||||||
videoBuffer_.write(reinterpret_cast<const char*>(buffer.cdata), buffer.size);
|
videoBuffer_.write(reinterpret_cast<const char*>(buffer.cdata), buffer.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QtVideoOutput::resize()
|
||||||
|
{
|
||||||
|
if (videoWidget_ != nullptr && videoContainer_ != nullptr) videoWidget_->resize(videoContainer_->size());
|
||||||
|
}
|
||||||
|
|
||||||
void QtVideoOutput::onStartPlayback()
|
void QtVideoOutput::onStartPlayback()
|
||||||
{
|
{
|
||||||
if (videoContainer_ == nullptr)
|
if (videoContainer_ == nullptr)
|
||||||
|
@ -82,8 +82,12 @@ IService::Pointer ServiceFactory::createVideoService(aasdk::messenger::IMessenge
|
|||||||
#ifdef USE_OMX
|
#ifdef USE_OMX
|
||||||
auto videoOutput(omxVideoOutput_);
|
auto videoOutput(omxVideoOutput_);
|
||||||
#else
|
#else
|
||||||
auto qtVideoOutput = new projection::QtVideoOutput(configuration_, activeArea_);
|
qtVideoOutput_ = new projection::QtVideoOutput(configuration_, activeArea_);
|
||||||
projection::IVideoOutput::Pointer videoOutput(qtVideoOutput, std::bind(&QObject::deleteLater, std::placeholders::_1));
|
if (activeCallback_ != nullptr) {
|
||||||
|
QObject::connect(qtVideoOutput_, &projection::QtVideoOutput::startPlayback, [callback = activeCallback_]() { callback(true); });
|
||||||
|
QObject::connect(qtVideoOutput_, &projection::QtVideoOutput::stopPlayback, [callback = activeCallback_]() { callback(false); });
|
||||||
|
}
|
||||||
|
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));
|
||||||
}
|
}
|
||||||
@ -128,9 +132,9 @@ IService::Pointer ServiceFactory::createInputService(aasdk::messenger::IMessenge
|
|||||||
}
|
}
|
||||||
|
|
||||||
QObject* inputObject = activeArea_ == nullptr ? qobject_cast<QObject*>(QApplication::instance()) : qobject_cast<QObject*>(activeArea_);
|
QObject* inputObject = activeArea_ == nullptr ? qobject_cast<QObject*>(QApplication::instance()) : qobject_cast<QObject*>(activeArea_);
|
||||||
projection::IInputDevice::Pointer inputDevice(std::make_shared<projection::InputDevice>(*inputObject, configuration_, std::move(screenGeometry_), std::move(videoGeometry)));
|
inputDevice_ = std::make_shared<projection::InputDevice>(*inputObject, 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(projection::IInputDevice::Pointer(inputDevice_)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServiceFactory::createAudioServices(ServiceList& serviceList, aasdk::messenger::IMessenger::Pointer messenger)
|
void ServiceFactory::createAudioServices(ServiceList& serviceList, aasdk::messenger::IMessenger::Pointer messenger)
|
||||||
@ -163,7 +167,18 @@ void ServiceFactory::createAudioServices(ServiceList& serviceList, aasdk::messen
|
|||||||
void ServiceFactory::setOpacity(unsigned int alpha)
|
void ServiceFactory::setOpacity(unsigned int alpha)
|
||||||
{
|
{
|
||||||
#ifdef USE_OMX
|
#ifdef USE_OMX
|
||||||
omxVideoOutput_->setOpacity(alpha);
|
if (omxVideoOutput_ != nullptr) omxVideoOutput_->setOpacity(alpha);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServiceFactory::resize()
|
||||||
|
{
|
||||||
|
screenGeometry_ = this->mapActiveAreaToGlobal(activeArea_);
|
||||||
|
if (inputDevice_ != nullptr) inputDevice_->setTouchscreenGeometry(screenGeometry_);
|
||||||
|
#ifdef USE_OMX
|
||||||
|
if (omxVideoOutput_ != nullptr) omxVideoOutput_->setDestRect(this->QRectToDestRect(screenGeometry_));
|
||||||
|
#else
|
||||||
|
if (qtVideoOutput_ != nullptr) qtVideoOutput_->resize();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user