128 lines
3.1 KiB
C++
Executable File
128 lines
3.1 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* PlaybackApp
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Christian Fröbel, NLSE, 2018-04-18
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <Plugins/AudioVideoManagement/Shared/avmshared_export.h>
|
|
#include <QString>
|
|
#include <QObject>
|
|
#include <memory>
|
|
#include <functional>
|
|
|
|
class QRect;
|
|
|
|
namespace AudioVideoManagement
|
|
{
|
|
|
|
class AvsApp;
|
|
class AvaControl;
|
|
|
|
// PlaybackApp cannot be a QObject, so we need a wrapper that takes signals, etc.
|
|
class AVMSHARED_EXPORT ObjectWrapper : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
ObjectWrapper(QObject *parent) : QObject(parent) {}
|
|
|
|
signals:
|
|
void signalVisible();
|
|
void signalPause();
|
|
void signalResume();
|
|
};
|
|
|
|
|
|
/**
|
|
* Represents a playback application -- either for video or for audio.
|
|
* Audio does not require the AVS dialog to be visible and we don't need
|
|
* a separate application in the Excon-sense for that. Use AppType::AlwaysHidden
|
|
* for audio.
|
|
*
|
|
* The Video PlaybackApp will cover a whole screen as all the other Excon apps do
|
|
* and will be placed in the same way (see AvsApp).
|
|
*
|
|
* PlaybackApp is a resource and can only be used by one client at the same time.
|
|
*
|
|
* @author Christian Fröbel
|
|
*/
|
|
class AVMSHARED_EXPORT PlaybackApp
|
|
{
|
|
public:
|
|
|
|
enum class AppType
|
|
{
|
|
Normal = 1, //!< Visible AVS-dialog, no auto-hide on release()
|
|
AutoHide, //!< Visible AVS-dialog, auto-hide on release()
|
|
AlwaysHidden //!< No visible AVS-dialog (for audio playback)
|
|
};
|
|
|
|
/**
|
|
* Use AppType::AlwaysHidden for Audio.
|
|
*/
|
|
PlaybackApp(const QString &dialogId, AvaControl *avaControl, AppType);
|
|
virtual ~PlaybackApp();
|
|
|
|
ObjectWrapper *objectWrapper() { return m_objectWrapper; }
|
|
const QString &dialogId() const { return m_dialogId; }
|
|
|
|
/** @return true if someone is using this App. */
|
|
bool inUse() const { return m_inUse; }
|
|
|
|
/**
|
|
* Resource acquisition.
|
|
* Don't use directly; use PlaybackAppHandle instead.
|
|
*/
|
|
///@{
|
|
/**
|
|
* May only be called when inUse() == false.
|
|
* Will implicitly show the underlying AvsApp.
|
|
*/
|
|
void acquire();
|
|
void acquire(const QRect &geometry);
|
|
void setGeometry(const QRect &geometry);
|
|
/**
|
|
* Will implicitly hide the underlying AvsApp when appType == AppType::AutoHide.
|
|
*/
|
|
void release();
|
|
|
|
void hide(bool andClose);
|
|
|
|
///@}
|
|
|
|
private:
|
|
const QString m_dialogId;
|
|
bool m_inUse{false};
|
|
bool m_autoHide;
|
|
std::unique_ptr<AvsApp> m_app; //!< only set when appType != AppType::AlwaysHidden
|
|
ObjectWrapper *m_objectWrapper { nullptr };
|
|
};
|
|
|
|
|
|
/**
|
|
* @author Christian Fröbel
|
|
*/
|
|
class AVMSHARED_EXPORT PlaybackAppHandle
|
|
{
|
|
public:
|
|
PlaybackAppHandle() = default;
|
|
explicit PlaybackAppHandle(PlaybackApp *app);
|
|
PlaybackAppHandle(PlaybackApp *app, const QRect &geometry);
|
|
|
|
operator bool() const { return m_app.get() != nullptr; }
|
|
|
|
const QString &dialogId() const { return m_app->dialogId(); }
|
|
void hide(bool andClose = false) { m_app->hide(andClose); }
|
|
ObjectWrapper *objectWrapper() { return m_app->objectWrapper(); }
|
|
|
|
private:
|
|
using Releaser = std::function<void (PlaybackApp *)>;
|
|
std::unique_ptr<PlaybackApp, Releaser> m_app;
|
|
};
|
|
|
|
} // namespace AudioVideoManagement
|