#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)
{
QMessageBox::critical(pWidget,
}
{
{
show_result(pWidget, nRes);
}
return nRes;
}
cRecorderControlViewSrv::cRecorderControlViewSrv()
{
m_strTitle =
cString(
"Demo Recorder Control");
m_pWidget = nullptr;
SetDescription("Use this UI Service to extend the ADTF System with a User Interface to control the ADTFDAT File Recorder.");
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)
{
}
if (m_pWidget)
{
std::list<tRecorderInfo> lstInfo;
if (!m_mapRecorders.empty())
{
for (auto it : m_mapRecorders)
{
tRecorderInfo sInfo;
sInfo.eState = it.second->GetCurrentState();
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();
object_list<adtf::services::IRecorder> lstRecorder;
int nIdx = 0;
for (auto it : lstRecorder)
{
INamedGraphObject* pNamedObject = ucom_cast<INamedGraphObject*>(it.Get());
if (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.
#define IS_FAILED(s)
Check if result is failed.
#define LOG_RESULT(code)
Log result to console.
#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...
tADTFRunLevel
The ADTF Runtime Level State are used to define a ADTF Runtime specialization for a adtf::ucom::ant::...
@ RL_StreamingGraph
The Streaminggraph level.
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.
error_code_type value
Value of this error code.