ADTF  3.18.2
Source Code for Demo Qt5 Player Control View Plugin
Location
./src/examples/src/adtf/system_services/gui/demo_player_control_view/
Namespace for entire ADTF SDK.
Build Environment
To see how to set up the build environment have a look at ADTF CMake Environment
this implementation shows:
Header
/*
* This file depends on Qt which is licensed under LGPLv3.
* See ADTF_DIR/3rdparty/qt5 and doc/license for detailed information.
*/
#ifndef _DEMO_PLAYER_CONTROL_VIEW_CLASS_HEADER_
#define _DEMO_PLAYER_CONTROL_VIEW_CLASS_HEADER_
class cPlayerControlViewSrv : public cQtUIService, public IControlView
{
public:
ADTF_CLASS_ID_NAME(cPlayerControlViewSrv, "demo_qt_player_control_view.ui_service.adtf.cid", "Demo Qt5 Player Control View");
protected:
cPlayerControlWidget* m_pWidget;
tTimeStamp m_tmLastUpdate = 0;
tTimeStamp m_tmMinInterval = 200000;
public:
cPlayerControlViewSrv();
tResult ServiceEvent(int nEventId,
uint32_t ui32Param1 = 0,
uint32_t ui32Param2 = 0,
void* pvData = nullptr,
int szData = 0) override;
protected:
QWidget* CreateView() override;
void ReleaseView() override;
tResult OnIdle() override;
public:
void OpenFile(const QString& strFile) override;
void Run() override;
void Pause() override;
void Play() override;
void Stop() override;
void SeekToTime(tTimeStamp tmTime) override;
};
#endif // _DEMO_PLAYER_CONTROL_VIEW_CLASS_HEADER_
#define REQUIRE_INTERFACE(_interface)
Macro usable with ADTF_CLASS_DEPENDENCIES() to require mandatory interfaces.
#define ADTF_CLASS_DEPENDENCIES(...)
Add interface ids (string literals,.
#define ADTF_CLASS_ID_NAME(_class, _strcid, _strclabel)
Common macro to enable correct treatment of class identifier AND Class Name by IClassInfo.
Definition: class_id.h:33
ADTF Playback Service Control interface to control the ADTF Player.
Definition: player_intf.h:388
Object pointer implementation used for reference counting on objects of type IObject.
Definition: object_ptr.h:163
Interface definition for the ADTF XSystem based on Qt.
qt_ui_service< adtf::system::ant::cADTFService > cQtUIService
UI Service basic implementation for cADTFService.
Definition: qt_ui_service.h:80
Implementation
/*
* This file depends on Qt which is licensed under LGPLv3.
* See ADTF_DIR/3rdparty/qt5 and doc/license for detailed information.
*/
#include "stdafx.h"
#include "demo_player_control_widget.h"
#include "demo_player_control_view.h"
ADTF_PLUGIN("Demo Qt5 Player Control View Plugin", cPlayerControlViewSrv);
#ifdef GetObject
#undef GetObject
#endif
#ifdef GetCurrentTime
#undef GetCurrentTime
#endif
void show_result(QWidget* pWidget, tResult nRes)
{
LOG_RESULT(nRes);
QMessageBox::critical(pWidget,
cString::Format("Error %d - [%s] ", nRes.GetErrorCode().value, nRes.GetErrorString()).GetPtr(),
nRes.GetDescription());
}
tResult local_set_run_level(QWidget* pWidget, tADTFRunLevel eLevel)
{
tResult nRes = _runtime->SetRunLevel(eLevel);
if (IS_FAILED(nRes))
{
show_result(pWidget, nRes);
}
return nRes;
}
cPlayerControlViewSrv::cPlayerControlViewSrv()
{
m_strTitle = cString("Demo Player Control");
m_pWidget = nullptr;
SetDefaultRunlevel(tADTFRunLevel::RL_FilterGraph);
// sets a short description for the component
SetDescription("Use this UI Service to extend the ADTF System with a User Interface to control the ADTFDAT File Player.");
// set help link to jump to documentation from ADTF Configuration Editor
SetHelpLink("$(ADTF_DIR)/doc/adtf_html/page_demo_player_control_view.html");
}
QWidget* cPlayerControlViewSrv::CreateView()
{
m_pWidget = new cPlayerControlWidget(nullptr, *this);
return m_pWidget;
}
void cPlayerControlViewSrv::ReleaseView()
{
delete m_pWidget;
m_pWidget = nullptr;
}
tResult cPlayerControlViewSrv::OnIdle()
{
if (cHighResTimer::GetTime() - m_tmLastUpdate < m_tmMinInterval)
{
}
if (m_pWidget)
{
cPlayerControlWidget::tPlayerInfo sInfo;
if (m_pPlayer)
{
sInfo.bPlayerPresent = true;
sInfo.eState = m_pPlayer->GetCurrentState();
sInfo.eLevel = static_cast<adtf::base::tADTFRunLevel>(_runtime->GetRunLevel());
//do not check ret val, they are intialized already
m_pPlayer->GetTimeRange(sInfo.tmBegin, sInfo.tmEnd);
sInfo.tmCurrent = m_pPlayer->GetCurrentTime();
//do not check ret val, they are intialized already
m_pPlayer->GetCurrentFileNames(adtf_string_intf(sInfo.strFile));
}
m_pWidget->Update(sInfo);
}
m_tmLastUpdate = cHighResTimer::GetTime();
}
tResult cPlayerControlViewSrv::ServiceEvent(int nEventId,
uint32_t ui32Param1,
uint32_t ui32Param2,
void* pvData,
int szData)
{
if (nEventId == IService::SE_ChangeRunLevel)
{
tADTFRunLevel eLevel = static_cast<tADTFRunLevel>(ui32Param1);
if (ui32Param2 == IRuntime::CRLF_PostIncrementLevel ||
ui32Param2 == IRuntime::CRLF_PostDecrementLevel)
{
//we do not synchronize this since ServiceEvent is always called within main context!
//OnIdle is within GUI context too
_runtime->GetObject(m_pPlayer);
}
else if (ui32Param2 == IRuntime::CRLF_PreDecrementLevel)
{
if (eLevel == tADTFRunLevel::RL_Running)
{
Pause();
}
}
}
return cQtUIService::ServiceEvent(nEventId, ui32Param1, ui32Param2, pvData, szData);
}
void cPlayerControlViewSrv::OpenFile(const QString& strFile)
{
if (m_pPlayer)
{
tADTFRunLevel eOldLevel = static_cast<tADTFRunLevel>(_runtime->GetRunLevel());
local_set_run_level(m_pWidget, tADTFRunLevel::RL_Session);
if (m_pPlayer)
{
tResult nRes = m_pPlayer->Open(static_cast<const char*>(strFile.toUtf8()), true);
if (IS_FAILED(nRes))
{
show_result(m_pWidget, nRes);
}
else
{
local_set_run_level(m_pWidget, eOldLevel);
}
}
}
}
void cPlayerControlViewSrv::Run()
{
local_set_run_level(m_pWidget, tADTFRunLevel::RL_Running);
}
void cPlayerControlViewSrv::Pause()
{
if (m_pPlayer)
{
m_pPlayer->Pause();
}
}
void cPlayerControlViewSrv::Play()
{
if (m_pPlayer)
{
m_pPlayer->Play();
}
}
void cPlayerControlViewSrv::Stop()
{
local_set_run_level(m_pWidget, tADTFRunLevel::RL_FilterGraph);
}
void cPlayerControlViewSrv::SeekToTime(tTimeStamp tmTime)
{
if (m_pPlayer)
{
m_pPlayer->SeekToTime(tmTime);
}
}
#define ADTF_PLUGIN(__plugin_identifier,...)
The ADTF Plugin Macro will add the code of a adtf::ucom::ant::IPlugin implementation.
Definition: adtf_plugin.h:22
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
#define RETURN_IF_POINTER_NULL(_ptr)
Return ERR_POINTER if _ptr is nullptr, which requires the calling function's return type to be tResul...
const tChar * GetDescription() const
Get user provided error description.
const tChar * GetErrorString() const
Get error code as string representation.
tErrorCode GetErrorCode() const
Get error code.
virtual tResult SetRunLevel(int8_t nRunLevel, bool bWait=true)=0
Set run level.
virtual tResult GetObject(iobject_ptr< IObject > &pObject, const char *strNameOID) const =0
Get registered object from object registry.
virtual int8_t GetRunLevel() const =0
Get current run level.
string_base< cStackString > cString
cString implementation for a stack string which works on stack if string is lower than A_UTILS_DEFAUL...
Definition: string.h:2778
tADTFRunLevel
The ADTF Runtime Level State are used to define a ADTF Runtime specialization for a adtf::ucom::ant::...
Definition: adtf_runtime.h:24
@ RL_Session
The session level.
Definition: adtf_runtime.h:30
@ RL_FilterGraph
The Filtergraph level.
Definition: adtf_runtime.h:34
adtf::ucom::IRuntime * _runtime
Global Runtime Pointer to reference to the current runtime.
#define adtf_string_intf(__string__)
The adtf_string_intf Macro helps to easily create a rvalue reference of a adtf::util::cString.
Definition: string_intf.h:371