39template<
typename INTERFACE,
typename PINTYPE>
43 typedef PINTYPE pin_type;
103 pPin->RegisterStreamer(*
this);
120 m_poPin->UnregisterStreamer(*
this);
142 if (pStreamType.
Get())
160 tResult EndStreaming()
override
176 public base::ant::runnable<base::ant::IRunnable::RUN_PUSH, ISampleStream::IPushReadEventSink>
182 std::mutex m_oReadLock;
188 std::function<
tResult(
tResult oStreamError)> m_fnStreamErrorCallback;
199 bool m_bValidType =
true;
249 RETURN_ERROR_DESC(ERR_NOT_SUPPORTED,
"Currently only PushRead mode is supported.");
253 std::lock_guard<std::mutex> _sync(m_oReadLock);
266 std::lock_guard<std::mutex> _sync(m_oReadLock);
285 m_fnAcceptTypeCallback = fnAcceptTypeCallback;
294 m_fnStreamErrorCallback = fnStreamErrorCallback;
301 std::lock_guard<std::mutex> _sync(m_oReadLock);
305 return m_pInStream->SetStreamError(oError);
315 pSampleInStream.
Reset(m_pInStream);
323 if (m_pLastReadStreamType)
325 pType.
Reset(m_pLastReadStreamType);
351#ifdef _PIPES_DEBUG_LOG
352 LOG_DUMP(
"Run Push Event in Reader");
364 std::lock_guard<std::mutex> _sync(m_oReadLock);
365 if (
IS_FAILED(m_pInStream->Read(oItem, tTimeStamp(0))))
371 RETURN_IF_FAILED(
Push(oItem, tmTimeofActivation));
392 return ERR_NOT_CONNECTED;
400 RETURN_IF_FAILED(m_pInStream->Read(oItem, tTimeStamp(0)));
404 RETURN_IF_FAILED(
Pop(oItem));
440 m_bValidType =
false;
464 void Reset()
override
466 m_pLastReadStreamType.Reset();
478 if (m_fnStreamErrorCallback)
480 return m_fnStreamErrorCallback(nError);
496 std::set<ISampleReaderQueue*> m_lstExternalQueues;
503 for (
auto pQueue : m_lstExternalQueues)
505 RETURN_IF_FAILED(pQueue->Push(oStreamItem, tsTime));
513 for (
auto pQueue : m_lstExternalQueues)
524 tResult ReadAllAvailableItems()
532 m_lstExternalQueues.insert(pExternalBuffer);
535 void UnregisterExternalQueue(ISampleReaderQueue* pExternalBuffer)
537 m_lstExternalQueues.erase(pExternalBuffer);
575 void Reset()
override
578 cSampleReader::Reset();
601 std::scoped_lock oGuard(m_oFrontQueue.oMutex);
608 std::scoped_lock oGuard(m_oFrontQueue.oMutex);
609 m_oFrontQueue.oQueue = {};
610 m_oConsumerQueue = {};
615 if (m_oConsumerQueue.empty())
617 std::scoped_lock oGuard(m_oFrontQueue.oMutex);
618 std::swap(m_oConsumerQueue, m_oFrontQueue.oQueue);
620 if (m_oConsumerQueue.empty())
624 const auto oResult = m_oConsumerQueue.front().CopyTo(oStreamItem);
625 m_oConsumerQueue.pop();
632 std::queue<cStreamItem> oQueue;
635 alignas(64) std::queue<cStreamItem> m_oConsumerQueue;
641 std::mutex m_oQueueMutex;
642 std::deque<cStreamItem> m_oItems;
644 size_t m_nSampleCount = 0;
649 std::lock_guard<std::mutex> oGuard(m_oQueueMutex);
650 m_oItems.emplace_back(oStreamItem);
655 CheckQueue(m_oItems);
661 std::lock_guard<std::mutex> oGuard(m_oQueueMutex);
669 std::lock_guard<std::mutex> oGuard(m_oQueueMutex);
672 RETURN_IF_FAILED(m_oLastType.CopyTo(oItem));
677 if (m_oItems.empty())
682 RETURN_IF_FAILED(m_oItems.front().CopyTo(oItem));
687 m_oItems.pop_front();
694 virtual void CheckQueue(
const std::deque<cStreamItem>& oItems) = 0;
699 m_oLastType = m_oItems.front();
705 m_oItems.pop_front();
708 size_t GetSampleCount()
710 return m_nSampleCount;
714template<
size_t MaxSize>
718 void CheckQueue(
const std::deque<cStreamItem>& oItems)
override
720 while (!oItems.empty() &&
728template<tTimeStamp TimeRange>
732 void CheckQueue(
const std::deque<cStreamItem>& oItems)
override
737 if (
IS_OK(oItems.back().GetSample(pLastSample)))
739 tTimeStamp nLastTime = pLastSample->GetTime();
740 while (oItems.size() > 1)
742 auto& oItem = oItems.front();
746 if (
IS_OK(oItem.GetSample(pSample)))
748 if (nLastTime - pSample->GetTime() < TimeRange)
767template<
typename INTERNAL_QUEUE,
768 bool STORE_LAST_SAMPLE =
true,
770class sample_reader :
public std::conditional<STORE_LAST_SAMPLE, cLastSampleReader, cSampleReader>::type
777 typedef typename std::conditional<STORE_LAST_SAMPLE, cLastSampleReader, cSampleReader>::type
base_class;
789 void Clear()
override
794 tResult Pop(IStreamItem& oItem)
override
818template<tTimeStamp TIME_RANGE,
bool STORELASTSAMPLE = true>
830template<
size_t MAX_SIZE,
bool STORELASTSAMPLE = true>
850 pSample.
Reset(pEmpty);
852 return oSampleReader;
863template<
typename DATATYPE>
869 oSampleData.
Reset(pSample);
875 return oSampleReader;
888 return oSampleReader;
900 return pStreamfunc(oSampleReader);
911 const char* strNameOfReader,
914 oReader.
SetName(strNameOfReader);
915 return oReader.
SetType(pStreamType);
926 using cExternalQueueSampleReader::cExternalQueueSampleReader;
977 fnAcceptTypeCallback);
997 uint32_t nSubStreamId,
1006 fnRequestTypeUpdateCallback);
1009 class cImplementation;
1010 std::unique_ptr<cImplementation> m_pImplementation;
1023template<
typename INTERNAL_QUEUE,
1024 bool STORE_LAST_SAMPLE =
true,
1029 INTERNAL_QUEUE m_oQueue;
1032 sample_reader():
cSampleReader(m_oQueue, ACCESS_MODE, STORE_LAST_SAMPLE)
1055 RETURN_IF_FAILED(pQueue->Push(oStreamItem, tsTime));
1094 m_oQueue.RegisterExternalQueue(pExternalBuffer);
1099 m_oQueue.UnregisterExternalQueue(pExternalBuffer);
1113template<tTimeStamp TIME_RANGE,
bool STORELASTSAMPLE = true>
1120template<
size_t MAX_SIZE,
bool STORELASTSAMPLE = true>
1130 const char* strNameOfReader,
1133 oReader.
SetName(strNameOfReader);
1134 return oReader.
SetType(pStreamType);
1140 pSample.
Reset(pEmpty);
1142 return oSampleReader;
1145template<
typename DATATYPE>
1146ISampleReader& operator>>(ISampleReader& oSampleReader, sample_data<DATATYPE>& oSampleData)
1149 if (
IS_OK(oSampleReader.GetNextSample(pSample)))
1151 oSampleData.Reset(pSample);
1155 oSampleData.Reset();
1157 return oSampleReader;
1163 return oSampleReader;
1168 return pStreamfunc(oSampleReader);
1206 void SetAcceptTypeCallback(
1208 fnAcceptTypeCallback);
1209 void SetStreamErrorCallback(
const std::function<
tResult(
tResult oStreamError)>& fnStreamErrorCallback);
1212 class cImplementation;
1213 std::unique_ptr<cImplementation> m_pImplementation;
1231using flash::make_sample_reader;
#define ADTF3_DEPRECATED(_depr_message_)
Definition adtf_base_deprecated.h:27
#define ADTF_BASE_COMPOSED_RESULT(_result,...)
for internal use
Definition exception_handling.h:27
#define LOG_DUMP(...)
Logs a dump message.
Definition log.h:382
#define IS_FAILED(s)
Check if result is failed.
Definition result.h:20
A_UTILS_NS::cResult tResult
For backwards compatibility and to bring latest version into scope.
Definition result.h:736
#define RETURN_ERROR_DESC(_code,...)
Same as RETURN_ERROR(_error) using a printf like parameter list for detailed error description.
Definition result.h:44
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
Definition result.h:29
#define RETURN_IF_THROWS(s)
if the expression throws an exception, returns a tResult containing the exception information.
Definition result.h:123
#define RETURN_ERROR(code)
Return specific error code, which requires the calling function's return type to be tResult.
Definition result.h:42
#define IS_OK(s)
Check if result is OK.
Definition result.h:17
Definition property_intf.h:213
Definition string_intf.h:29
virtual tResult Pop(IStreamItem &oStreamItem)=0
Returns the next sample from the queue.
virtual tResult Push(const IStreamItem &oStreamItem, tTimeStamp tmTime)=0
Push a new value to the internal sample queue.
Interface to create a sample reader buffer.
Definition samplestreamer_intf.h:96
Definition samplestreamaccess_intf.h:21
tMode
Definition samplestreamaccess_intf.h:26
@ AsyncQueue
Definition samplestreamaccess_intf.h:34
@ PushRead
Definition samplestreamaccess_intf.h:31
@ Push
Definition samplestreamaccess_intf.h:37
Definition samplestream_intf.h:41
Definition samplestream_intf.h:30
virtual tResult Open(const char *strName, adtf::ucom::ant::iobject_ptr< ISampleInStream > &pInStream, const adtf::ucom::ant::iobject_ptr< const IStreamType > &pInitialAcceptedStreamType, IPushReadEventSink *&pPushEventSink, ISampleStreamAccess::tMode ui32Mode, size_t szQueueSize)=0
Definition streamitem_intf.h:25
virtual tType GetType() const =0
@ StreamType
item is a IStreamType. Mind: All StreamType changes will be queue too !!
Definition streamitem_intf.h:36
@ Sample
item is a queue item contains a ISample
Definition streamitem_intf.h:38
virtual tResult GetStreamType(ucom::ant::iobject_ptr< const IStreamType > &pStreamType) const =0
Implementation of a adtf::streaming::ant::ISampleReaderQueue with dynamic growing sample queue.
Definition samplereader.h:597
tResult Push(const IStreamItem &oStreamItem, tTimeStamp) override
Push a new value to the internal sample queue.
Definition samplereader.h:599
tResult Pop(IStreamItem &oStreamItem) override
Returns the next sample from the queue.
Definition samplereader.h:613
void Clear() override
Definition samplereader.h:606
Sample reader which allows the registration of external queue.
Definition samplereader.h:493
cSampleReader()
Definition samplereader.h:212
tResult Push(const IStreamItem &oStreamItem, tTimeStamp tsTime) override
Push a new value to the internal sample queue.
Definition samplereader.h:501
tResult Pop(IStreamItem &) override
Returns the next sample from the queue.
Definition samplereader.h:519
void Clear() override
Definition samplereader.h:511
Sample reader which allows the registration of external queue.
Definition samplereader.h:924
cExternelQueueSampleReader()
Definition samplereader.h:934
Sample reader which always provides the last successful received sample.
Definition samplereader.h:545
cSampleReader()
Definition samplereader.h:212
tResult ReadNextSample(ucom::ant::iobject_ptr< const ISample > &pSample) override
Collect the next sample by overriding the adtf::streaming::ant::cSampleReader::ReadNextSample.
Definition samplereader.h:585
tResult GetLastSample(ucom::ant::iobject_ptr< const ISample > &pSample)
Definition samplereader.h:561
ucom::object_ptr< const ISample > m_pLastValidSample
Last Sample Reference.
Definition samplereader.h:548
Definition samplereader.h:639
tResult Push(const IStreamItem &oStreamItem, tTimeStamp) override
Push a new value to the internal sample queue.
Definition samplereader.h:647
tResult Pop(IStreamItem &oItem)
Returns the next sample from the queue.
Definition samplereader.h:667
void Clear() override
Definition samplereader.h:659
The default Sample Reader will read the incomung Stream of a IInPin. This sample reader has no intern...
Definition samplereader.h:177
virtual tResult AcceptType(const ucom::ant::iobject_ptr< const IStreamType > &pStreamType)
Accept or reject a new stream type.
cSampleReader()
Definition samplereader.h:212
tResult SetStreamError(const tResult &oError)
Definition samplereader.h:299
virtual tResult Pop(IStreamItem &oStreamItem)=0
Returns the next sample from the queue.
tResult Push(tTimeStamp tmTimeofActivation)
internal Push operation to implement pushread mode
Definition samplereader.h:347
virtual tResult ReadNextSample(ucom::ant::iobject_ptr< const ISample > &pSample)
Definition samplereader.h:388
void GetSampleInStream(ucom::ant::iobject_ptr< ISampleInStream > &pSampleInStream)
Returns the connected ISampleInStream.
Definition samplereader.h:313
void GetLastType(ucom::ant::iobject_ptr< const IStreamType > &pType)
Returns the connected ISampleInStream.
Definition samplereader.h:321
tResult BeginStreaming(ISampleStream &oSampleStream) override
Definition samplereader.h:242
void SetAcceptTypeCallback(const std::function< tResult(const ucom::iobject_ptr< const IStreamType > &pStreamType)> &fnAcceptTypeCallback)
Sets a callback function which is called while a Stream Type is received.
Definition samplereader.h:282
virtual tResult GetNextSample(ucom::ant::iobject_ptr< const ISample > &pSample)
Definition samplereader.h:340
tResult EndStreaming() override
Definition samplereader.h:263
void SetStreamErrorCallback(const std::function< tResult(tResult oStreamError)> &fnStreamErrorCallback)
A callback function to react on stream errors.
Definition samplereader.h:292
tResult ProcessStreamItem(const IStreamItem &oStreamItem)
Definition samplereader.h:429
cSampleReader(ISampleStreamAccess::tMode eAccessMode)
Definition samplereader.h:221
Definition streamitem_intf.h:105
tType GetType() const noexcept override
Definition streamitem_intf.h:169
tResult GetSample(ucom::ant::iobject_ptr< const ISample > &pSample) const noexcept override
Definition streamitem_intf.h:203
Definition sample_data.h:32
tResult Reset(const ucom::ant::iobject_ptr< const ISample > &pSample)
Definition sample_data.h:151
A Possible Sample Reader of a Trigger Function! Sample reader with a internal queue,...
Definition samplereader.h:771
std::conditional< STORE_LAST_SAMPLE, cLastSampleReader, cSampleReader >::type base_class
base class
Definition samplereader.h:777
cDynamicSampleReaderQueue m_oInternalQueue
Definition samplereader.h:774
virtual ~sample_streamer()
DTOR.
Definition samplereader.h:73
sample_streamer()=default
CTOR.
sample_streamer & operator=(sample_streamer &&)=delete
deleted move operator
tResult GetName(base::ant::IString &&strName) const
Definition samplereader.h:129
sample_streamer(sample_streamer &&)=delete
deleted move CTOR
void ResetPin(ucom::ant::object_ptr< PINTYPE > &pPin)
Definition samplereader.h:95
sample_streamer & operator=(const sample_streamer &)=delete
deleted copy operator
ucom::object_ptr< const IStreamType > m_pStreamType
Definition samplereader.h:49
sample_streamer(const char *strName, const ucom::ant::iobject_ptr< const IStreamType > &pStreamType)
Definition samplereader.h:68
adtf_util::cString m_strName
Definition samplereader.h:47
tResult SetType(const ucom::ant::iobject_ptr< const IStreamType > &pStreamType)
Definition samplereader.h:140
void ResetPin()
Definition samplereader.h:116
ucom::object_ptr< cInPin > m_poPin
Definition samplereader.h:51
void SetName(const char *strName)
Definition samplereader.h:84
sample_streamer(const sample_streamer &)=delete
deleted copy CTOR
Definition samplereader.h:716
Definition samplereader.h:730
cSampleReader(ant::ISampleReaderQueue &oQueue, ant::ISampleStreamAccess::tMode eAccessMode, bool bStoreLastSample)
Definition samplereader.h:1080
Definition samplestreamer_intf.h:188
virtual tResult GetLastType(ucom::ant::iobject_ptr< const IStreamType > &pType)=0
virtual tResult GetNextSample(ucom::ant::iobject_ptr< const ant::ISample > &pSample)=0
virtual void SetName(const char *strName)=0
virtual tResult SetType(const ucom::ant::iobject_ptr< const ant::IStreamType > &pStreamType)=0
Definition samplereader.h:1090
Definition samplereader.h:1038
void Clear() override
Definition samplereader.h:1061
tResult Pop(IStreamItem &) override
Returns the next sample from the queue.
Definition samplereader.h:1069
tResult Push(const IStreamItem &oStreamItem, tTimeStamp tsTime) override
Push a new value to the internal sample queue.
Definition samplereader.h:1051
std::set< ISampleReaderQueue * > m_oExternalQueues
A set of other registered buffer.
Definition samplereader.h:1076
The default Sample Reader will read the incomung Stream of a IInPin. This sample reader has no intern...
Definition samplereader.h:948
tResult GetLastSample(ucom::ant::iobject_ptr< const ant::ISample > &pSample) override
tResult GetNextSample(ucom::ant::iobject_ptr< const ant::ISample > &pSample) override
tResult ReadAllAvailableItems() override
tResult GetType(ucom::ant::iobject_ptr< const ant::IStreamType > &pStreamType) const override
void SetName(const char *strName) override
void SetAcceptTypeCallback(const std::function< tResult(const ucom::ant::iobject_ptr< const ant::IStreamType > &pStreamType)> &fnAcceptTypeCallback)
Sets a callback function which is called while a Stream Type is received.
void SetStreamErrorCallback(const std::function< tResult(tResult oStreamError)> &fnStreamErrorCallback)
A callback function to react on stream errors.
tResult SetStreamerPin(const ucom::ant::iobject_ptr< IStreamerPin > &pStreamerPin) override
tResult GetName(base::ant::IString &&strName) override
tResult SetStreamError(tResult oError) override
tResult BeginStreaming(ISampleStream &oSampleStream) override
cSampleReader(ant::ISampleReaderQueue &oQueue, ant::ISampleStreamAccess::tMode eAccessMode, bool bStoreLastSample)
tResult GetLastType(ucom::ant::iobject_ptr< const ant::IStreamType > &pType) override
tResult SetType(const ucom::ant::iobject_ptr< const ant::IStreamType > &pStreamType) override
tResult RequestSamples(ucom::ant::iobject_ptr< hollow::IStreamingRequest > &pRequest, uint32_t nSubStreamId, const base::ant::IProperties *pRequestProperties=nullptr)
tResult EndStreaming() override
void SetSynchronousTypeUpdateCallback(const std::function< tResult(const ucom::ant::iobject_ptr< const ant::IStreamType > &pStreamType)> &fnRequestTypeUpdateCallback)
Reads and stores Samples within the given queue implementation INTERNAL_QUEUE.
Definition samplereader.h:1027
Definition samplereader.h:1180
tResult EndStreaming() override
tResult SetStreamerPin(const ucom::ant::iobject_ptr< flash::IStreamerPin > &pStreamerPin) override
tResult GetNextSample(ucom::ant::iobject_ptr< const ant::ISample > &pSample) override
tResult ReadAllAvailableItems() override
void SetName(const char *strName) override
tResult SetType(const ucom::ant::iobject_ptr< const ant::IStreamType > &pStreamType) override
tResult GetLastType(ucom::ant::iobject_ptr< const ant::IStreamType > &pType) override
tResult GetName(base::ant::IString &&strName) override
tResult BeginStreaming(ant::ISampleStream &pStream) override
tResult SetStreamError(tResult oError) override
tResult GetType(ucom::ant::iobject_ptr< const ant::IStreamType > &pStreamType) const override
tResult GetLastSample(ucom::ant::iobject_ptr< const ant::ISample > &pSample) override
virtual tResult Reset(const iobject_ptr< T > &i_oOther)=0
Reset this object_ptr<> with the content of another iobject_ptr<>
virtual T * Get() const =0
Get raw pointer to shared object.
Base object pointer to realize binary compatible reference counting in interface methods.
Definition object_ptr_intf.h:112
Definition object_ptr.h:384
adtf::base::runnable< DEFAULT_ACTIVATION_TYPE, ANT_INTERFACE, flash::IRunnable, CALLABLE > runnable
Definition runnable.h:231
Namespace for all functionality of the ADTF Streaming SDK provided since v3.0.
Definition bindingproxyoutport.h:16
size_limited_sample_reader< 1 > cSingleSampleReader
The cSingleSampleReader will create a sample reader which will create a internal sample queue with on...
Definition samplereader.h:837
sample_reader< cDynamicSampleReaderQueue > cDynamicSampleReader
The cDynamicSampleReader will create a sample reader which will create a internal sample queue with u...
Definition samplereader.h:807
sample_reader< time_limited_sample_reader_queue< TIME_RANGE >, STORELASTSAMPLE > time_limited_sample_reader
Definition samplereader.h:819
sample_reader< size_limited_sample_reader_queue< MAX_SIZE >, STORELASTSAMPLE > size_limited_sample_reader
Definition samplereader.h:831
tResult make_sample_reader(cSampleReader &oReader, const char *strNameOfReader, const ucom::iobject_ptr< const IStreamType > &pStreamType)
Definition samplereader.h:910
const ISampleInStream & operator>>(const ISampleInStream &oStreamReader, IStreamItem &oItem)
Definition sampleinstream_intf.h:80
size_limited_sample_reader< 1 > cSingleSampleReader
The cSingleSampleReader will create a sample reader which will create a internal sample queue with on...
Definition samplereader.h:1127
sample_reader< ant::size_limited_sample_reader_queue< MAX_SIZE >, STORELASTSAMPLE > size_limited_sample_reader
Definition samplereader.h:1121
sample_reader< ant::cDynamicSampleReaderQueue > cDynamicSampleReader
The cDynamicSampleReader will create a sample reader which will create a internal sample queue with u...
Definition samplereader.h:1107
sample_reader< ant::time_limited_sample_reader_queue< TIME_RANGE >, STORELASTSAMPLE > time_limited_sample_reader
Definition samplereader.h:1114
Namespace for all functionality of the ADTF Streaming SDK provided since v3.10.
Definition samplereader.h:1174
Namespace for the ADTF Streaming SDK.
Definition bindingproxyinport.h:14
ant::iobject_ptr< T > iobject_ptr
Alias always bringing the latest version of ant::iobject_ptr into scope.
Definition object_ptr_intf.h:437
object_ptr< Implementation > make_object_ptr(Args &&... args)
Alias always bringing the latest version of ant::make_object_ptr() into scope.
Definition object_ptr_utilities.h:129
Namespace for all functionality provided by ADTF and its SDKs.
Definition adtf_client_connector.h:14
#define ADTF_RUN_FUNCTION(_fcName_)
Definition runnable.h:239