ADTF  3.18.2
Source Code for Demo Qt5 Recorder Control View Plugin
Location
./src/examples/src/adtf/system_services/gui/demo_recorder_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_RECORDER_CONTROL_VIEW_CLASS_HEADER_
#define _DEMO_RECORDER_CONTROL_VIEW_CLASS_HEADER_
class cRecorderControlViewSrv : public cQtUIService, public IRecorderControlView
{
public:
ADTF_CLASS_ID_NAME(cRecorderControlViewSrv, "demo_qt_recorder_control_view.ui_service.adtf.cid", "Demo Qt5 Recorder Control View");
protected:
cRecorderControlWidget* m_pWidget;
std::map<cString, object_ptr<adtf::services::IRecorder>> m_mapRecorders;
tTimeStamp m_tmLastUpdate = 0;
tTimeStamp m_tmMinInterval = 200000;
public:
cRecorderControlViewSrv();
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 StartRecording(const QString& strRecorderName) override;
void StopRecording(const QString& strRecorderName) override;
void SplitRecording(const QString& strRecorderName) override;
};
#endif // _DEMO_RECORDER_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
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_rec_ctrl_widget.h"
#include "demo_rec_ctrl_view.h"
ADTF_PLUGIN("Demo Qt5 Recorder Control View Plugin", cRecorderControlViewSrv);
#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;
}
cRecorderControlViewSrv::cRecorderControlViewSrv()
{
m_strTitle = cString("Demo Recorder Control");
m_pWidget = nullptr;
SetDefaultRunlevel(tADTFRunLevel::RL_StreamingGraph);
// 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 Recorder.");
// set help link to jump to documentation from ADTF Configuration Editor
SetHelpLink("$(ADTF_DIR)/doc/adtf_html/page_demo_recorder_control_view.html");
}
QWidget* cRecorderControlViewSrv::CreateView()
{
m_pWidget = new cRecorderControlWidget(nullptr, *this);
return m_pWidget;
}
void cRecorderControlViewSrv::ReleaseView()
{
delete m_pWidget;
m_pWidget = nullptr;
}
tResult cRecorderControlViewSrv::OnIdle()
{
if (cHighResTimer::GetTime() - m_tmLastUpdate < m_tmMinInterval)
{
RETURN_ERROR(ERR_NOERROR);
}
if (m_pWidget)
{
std::list<tRecorderInfo> lstInfo;
if (!m_mapRecorders.empty())
{
for (auto it : m_mapRecorders)
{
tRecorderInfo sInfo;
sInfo.eState = it.second->GetCurrentState();
it.second->GetCurrentFileName(adtf_string_intf(sInfo.strFile));
sInfo.strRecorderName = it.first.GetPtr();
lstInfo.push_back(sInfo);
}
}
m_pWidget->Update(lstInfo);
}
m_tmLastUpdate = cHighResTimer::GetTime();
}
tResult cRecorderControlViewSrv::ServiceEvent(int nEventId,
uint32_t ui32Param1,
uint32_t ui32Param2,
void* pvData,
int szData)
{
if (nEventId == IService::SE_ChangeRunLevel)
{
if (ui32Param2 == IRuntime::CRLF_PostIncrementLevel ||
ui32Param2 == IRuntime::CRLF_PostDecrementLevel)
{
m_mapRecorders.clear();
//we do not synchronize this since ServiceEvent is always called within main context!
//OnIdle is within GUI context too
object_list<adtf::services::IRecorder> lstRecorder;
int nIdx = 0;
for (auto it : lstRecorder)
{
cString strRecorderName;
INamedGraphObject* pNamedObject = ucom_cast<INamedGraphObject*>(it.Get());
if (pNamedObject)
{
strRecorderName = get_named_graph_object_full_name(*pNamedObject);
}
else
{
strRecorderName = cString::Format("Recorder_index_%d", ++nIdx);
}
m_mapRecorders[strRecorderName] = it;
}
}
}
return cQtUIService::ServiceEvent(nEventId, ui32Param1, ui32Param2, pvData, szData);
}
void cRecorderControlViewSrv::StartRecording(const QString& strRecorderName)
{
auto itRecorder = m_mapRecorders.find(cString(static_cast<const char*>(strRecorderName.toUtf8())));
if (itRecorder != m_mapRecorders.end())
{
itRecorder->second->Start("");
}
}
void cRecorderControlViewSrv::StopRecording(const QString& strRecorderName)
{
auto itRecorder = m_mapRecorders.find(cString(static_cast<const char*>(strRecorderName.toUtf8())));
if (itRecorder != m_mapRecorders.end())
{
itRecorder->second->Stop("");
}
}
void cRecorderControlViewSrv::SplitRecording(const QString& strRecorderName)
{
auto itRecorder = m_mapRecorders.find(cString(static_cast<const char*>(strRecorderName.toUtf8())));
if (itRecorder != m_mapRecorders.end())
{
itRecorder->second->Split("");
}
}
#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_ERROR(code)
Return specific error code, 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.
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_StreamingGraph
The Streaminggraph level.
Definition: adtf_runtime.h:32
tResult get_recorders(adtf::ucom::object_list< RecorderInterface > &lstRecorders)
Gets the all registered recorder instances.
adtf_util::cString get_named_graph_object_full_name(const INamedGraphObject &oGraphObject)
Helper function to retrieve a full qualified unique name of an object registered in IFilterGraph.
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