ADTF
Loading...
Searching...
No Matches
samplereader.h
Go to the documentation of this file.
1
7#pragma once
9#include "streamtype_intf.h"
10#include "sample_intf.h"
11#include "sample.h"
12#include "streamtype.h"
14#include "streammetatypeplain.h"
15#include "pin.h"
16#include "sampleinstream_intf.h"
17#include "samplestream_intf.h"
18#include "streamitem_intf.h"
21
22#include <adtf_utils.h>
25
26namespace adtf
27{
28namespace streaming
29{
30namespace ant
31{
32
39template<typename INTERFACE, typename PINTYPE>
40class sample_streamer : public INTERFACE
41{
42public:
43 typedef PINTYPE pin_type;
44
45protected:
47 adtf_util::cString m_strName;
52
61
62public:
64 sample_streamer() = default;
68 sample_streamer(const char* strName, const ucom::ant::iobject_ptr<const IStreamType>& pStreamType):
69 m_strName(strName), m_pStreamType(pStreamType)
70 {
71 }
72
74 {
75 ResetPin();
76 }
77
78public:
84 void SetName(const char* strName)
85 {
86 m_strName = strName;
87 }
88
96 {
97 if (m_poPin)
98 {
99 ResetPin();
100 }
101 if (pPin)
102 {
103 pPin->RegisterStreamer(*this);
104 m_poPin = pPin;
105 }
106 else
107 {
108 ResetPin();
109 }
110 }
111
116 void ResetPin()
117 {
118 if (m_poPin)
119 {
120 m_poPin->UnregisterStreamer(*this);
121 m_poPin = nullptr;
122 }
123 }
124
130 {
131 return strName.Set(m_strName);
132 }
133
141 {
142 if (pStreamType.Get())
143 {
145 }
146 else
147 {
148 m_pStreamType = nullptr;
149 }
151 }
152
153public: // implements ISampleStreamer
154 tResult GetType(ucom::ant::iobject_ptr<const IStreamType>& pStreamType) const override
155 {
156 RETURN_IF_FAILED(pStreamType.Reset(m_pStreamType));
158 }
159
160 tResult EndStreaming() override
161 {
163 }
164};
165
174 public sample_streamer<ISampleReader, cInPin>,
175 public ISampleReaderQueue,
176 public base::ant::runnable<base::ant::IRunnable::RUN_PUSH, ISampleStream::IPushReadEventSink>
177{
178private:
182 std::mutex m_oReadLock;
186 std::function<tResult(const ucom::iobject_ptr<const IStreamType>& pStreamType)> m_fnAcceptTypeCallback;
188 std::function<tResult(tResult oStreamError)> m_fnStreamErrorCallback;
189
194
199 bool m_bValidType = true;
203 ucom::object_ptr<const IStreamType> m_pLastReadStreamType;
204
206 ISampleStreamAccess::tMode m_eAccessMode;
207
208public:
212 cSampleReader(): runnable_type(ADTF_RUN_FUNCTION(Push)), m_eAccessMode(ISampleStreamAccess::PushRead)
213 {
214 }
215
222 runnable_type(ADTF_RUN_FUNCTION(Push)), m_eAccessMode(eAccessMode)
223 {
224 }
225
240
241public:
242 tResult BeginStreaming(ISampleStream& oSampleStream) override
243 {
244 EndStreaming();
245
246 // async mode is not working yet.
247 if (m_eAccessMode != ISampleStreamAccess::tMode::PushRead)
248 {
249 RETURN_ERROR_DESC(ERR_NOT_SUPPORTED, "Currently only PushRead mode is supported.");
250 }
251
252 {
253 std::lock_guard<std::mutex> _sync(m_oReadLock);
254
256 //@TODO : Something for TYPE Checking !!!
257 RETURN_IF_FAILED(oSampleStream.Open(m_strName, m_pInStream, m_pStreamType, pSink, m_eAccessMode, 0));
258 }
259
261 }
262
264 {
265 {
266 std::lock_guard<std::mutex> _sync(m_oReadLock);
267 // this will automatically close
268 m_pInStream.Reset();
269 Clear();
270 }
272 }
273
283 const std::function<tResult(const ucom::iobject_ptr<const IStreamType>& pStreamType)>& fnAcceptTypeCallback)
284 {
285 m_fnAcceptTypeCallback = fnAcceptTypeCallback;
286 }
287
292 void SetStreamErrorCallback(const std::function<tResult(tResult oStreamError)>& fnStreamErrorCallback)
293 {
294 m_fnStreamErrorCallback = fnStreamErrorCallback;
295 }
296
297public:
300 {
301 std::lock_guard<std::mutex> _sync(m_oReadLock);
302 if (m_pInStream)
303 {
304 // report the error !!
305 return m_pInStream->SetStreamError(oError);
306 }
307 RETURN_ERROR(ERR_NOT_CONNECTED);
308 }
309
314 {
315 pSampleInStream.Reset(m_pInStream);
316 }
317
322 {
323 if (m_pLastReadStreamType)
324 {
325 pType.Reset(m_pLastReadStreamType);
326 }
327 else
328 {
329 pType.Reset(m_pStreamType);
330 }
331 }
332
341 {
342 return ReadNextSample(pSample);
343 }
344
345protected:
347 tResult Push(tTimeStamp tmTimeofActivation)
348 {
349// implementing Push
350// this will be done sync
351#ifdef _PIPES_DEBUG_LOG
352 LOG_DUMP("Run Push Event in Reader");
353#endif
354 if (!m_pInStream)
355 {
356 RETURN_ERROR(ERR_NOT_CONNECTED);
357 }
358
359 while (true)
360 {
361 cStreamItem oItem;
362 {
363 // very short LOCK !!
364 std::lock_guard<std::mutex> _sync(m_oReadLock);
365 if (IS_FAILED(m_pInStream->Read(oItem, tTimeStamp(0))))
366 {
367 break;
368 }
369 }
370
371 RETURN_IF_FAILED(Push(oItem, tmTimeofActivation));
372 }
373
375 }
376
377protected:
389 {
390 if (!m_pInStream)
391 {
392 return ERR_NOT_CONNECTED;
393 }
394
395 while (true)
396 {
397 cStreamItem oItem;
398 if (m_pInStream->GetMode() == ISampleStreamAccess::AsyncQueue)
399 {
400 RETURN_IF_FAILED(m_pInStream->Read(oItem, tTimeStamp(0)));
401 }
402 else
403 {
404 RETURN_IF_FAILED(Pop(oItem));
405 }
406
407 if (IS_OK(ProcessStreamItem(oItem)))
408 {
409 if (oItem.GetType() == IStreamItem::tType::Sample)
410 {
411 return oItem.GetSample(pSample);
412 }
413 }
414 }
415 }
416
430 {
431 switch (oStreamItem.GetType())
432 {
434 {
436 RETURN_IF_FAILED(oStreamItem.GetStreamType(pHelper));
437 tResult nError = AcceptType(pHelper);
438 if (IS_FAILED(nError))
439 {
440 m_bValidType = false;
441 RETURN_IF_FAILED(
442 HandleStreamError(ADTF_BASE_COMPOSED_RESULT(nError, "Stream type is not accepted by reader.")));
443 }
444 else
445 {
446 m_bValidType = true;
447 }
448 break;
449 }
450 default:
451 {
452 if (!m_bValidType)
453 {
454 RETURN_ERROR(ERR_INVALID_TYPE);
455 }
456 break;
457 }
458 }
459
461 }
462
463public:
464 void Reset() override
465 {
466 m_pLastReadStreamType.Reset();
467 Clear();
468 }
469
470public:
474
475protected:
476 tResult HandleStreamError(tResult nError)
477 {
478 if (m_fnStreamErrorCallback)
479 {
480 return m_fnStreamErrorCallback(nError);
481 }
482 else
483 {
484 return SetStreamError(nError);
485 }
486 }
487};
488
493{
494private:
496 std::set<ISampleReaderQueue*> m_lstExternalQueues;
497
498public:
500
501 tResult Push(const IStreamItem& oStreamItem, tTimeStamp tsTime) override
502 {
503 for (auto pQueue : m_lstExternalQueues)
504 {
505 RETURN_IF_FAILED(pQueue->Push(oStreamItem, tsTime));
506 }
507
509 };
510
511 void Clear() override
512 {
513 for (auto pQueue : m_lstExternalQueues)
514 {
515 pQueue->Clear();
516 }
517 }
518
519 tResult Pop(IStreamItem& /* oStreamItem */) override
520 {
521 RETURN_ERROR(ERR_EMPTY);
522 }
523
524 tResult ReadAllAvailableItems()
525 {
526 return cSampleReader::Push(0);
527 }
528
529public:
530 void RegisterExternalQueue(ISampleReaderQueue* pExternalBuffer)
531 {
532 m_lstExternalQueues.insert(pExternalBuffer);
533 }
534
535 void UnregisterExternalQueue(ISampleReaderQueue* pExternalBuffer)
536 {
537 m_lstExternalQueues.erase(pExternalBuffer);
538 }
539};
540
545{
546protected:
549
550public:
552
562 {
564 while (IS_OK(ReadNextSample(pDummy)))
565 ;
566
568 {
569 RETURN_ERROR(ERR_EMPTY);
570 }
571
572 return pSample.Reset(m_pLastValidSample);
573 }
574
575 void Reset() override
576 {
577 m_pLastValidSample = nullptr;
578 cSampleReader::Reset();
579 }
580
581protected:
586 {
587 RETURN_IF_FAILED(cSampleReader::ReadNextSample(pSample));
588 m_pLastValidSample.Reset(pSample);
590 }
591};
592
597{
598public: // implements ISampleReaderQueue
599 tResult Push(const IStreamItem& oStreamItem, tTimeStamp /* tmTime */) override
600 {
601 std::scoped_lock oGuard(m_oFrontQueue.oMutex);
602 RETURN_IF_THROWS(m_oFrontQueue.oQueue.emplace(oStreamItem));
604 }
605
606 void Clear() override
607 {
608 std::scoped_lock oGuard(m_oFrontQueue.oMutex);
609 m_oFrontQueue.oQueue = {};
610 m_oConsumerQueue = {};
611 }
612
613 tResult Pop(IStreamItem& oStreamItem) override
614 {
615 if (m_oConsumerQueue.empty())
616 {
617 std::scoped_lock oGuard(m_oFrontQueue.oMutex);
618 std::swap(m_oConsumerQueue, m_oFrontQueue.oQueue);
619 }
620 if (m_oConsumerQueue.empty())
621 {
622 RETURN_ERROR(ERR_EMPTY);
623 }
624 const auto oResult = m_oConsumerQueue.front().CopyTo(oStreamItem);
625 m_oConsumerQueue.pop();
626 return oResult;
627 }
628
629private:
630 struct alignas(64)
631 {
632 std::queue<cStreamItem> oQueue;
633 std::mutex oMutex;
634 } m_oFrontQueue;
635 alignas(64) std::queue<cStreamItem> m_oConsumerQueue;
636};
637
639{
640private:
641 std::mutex m_oQueueMutex;
642 std::deque<cStreamItem> m_oItems;
643 cStreamItem m_oLastType;
644 size_t m_nSampleCount = 0;
645
646public:
647 tResult Push(const IStreamItem& oStreamItem, tTimeStamp /* tmTime */) override
648 {
649 std::lock_guard<std::mutex> oGuard(m_oQueueMutex);
650 m_oItems.emplace_back(oStreamItem);
651 if (oStreamItem.GetType() == IStreamItem::tType::Sample)
652 {
653 ++m_nSampleCount;
654 }
655 CheckQueue(m_oItems);
657 }
658
659 void Clear() override
660 {
661 std::lock_guard<std::mutex> oGuard(m_oQueueMutex);
662 m_oItems.clear();
663 m_oLastType = cStreamItem();
664 m_nSampleCount = 0;
665 }
666
668 {
669 std::lock_guard<std::mutex> oGuard(m_oQueueMutex);
670 if (m_oLastType.GetType() == IStreamItem::tType::StreamType)
671 {
672 RETURN_IF_FAILED(m_oLastType.CopyTo(oItem));
673 m_oLastType = cStreamItem();
674 }
675 else
676 {
677 if (m_oItems.empty())
678 {
679 RETURN_ERROR(ERR_EMPTY);
680 }
681
682 RETURN_IF_FAILED(m_oItems.front().CopyTo(oItem));
683 if (m_oItems.front().GetType() == IStreamItem::tType::Sample)
684 {
685 --m_nSampleCount;
686 }
687 m_oItems.pop_front();
688 }
689
691 }
692
693protected:
694 virtual void CheckQueue(const std::deque<cStreamItem>& oItems) = 0;
695 void PopFront()
696 {
697 if (m_oItems.front().GetType() == IStreamItem::tType::StreamType)
698 {
699 m_oLastType = m_oItems.front();
700 }
701 else
702 {
703 --m_nSampleCount;
704 }
705 m_oItems.pop_front();
706 }
707
708 size_t GetSampleCount()
709 {
710 return m_nSampleCount;
711 }
712};
713
714template<size_t MaxSize>
716{
717protected:
718 void CheckQueue(const std::deque<cStreamItem>& oItems) override
719 {
720 while (!oItems.empty() &&
721 (GetSampleCount() > MaxSize || oItems.front().GetType() == IStreamItem::tType::StreamType))
722 {
723 PopFront();
724 }
725 }
726};
727
728template<tTimeStamp TimeRange>
730{
731protected:
732 void CheckQueue(const std::deque<cStreamItem>& oItems) override
733 {
734 if (oItems.back().GetType() == IStreamItem::tType::Sample)
735 {
737 if (IS_OK(oItems.back().GetSample(pLastSample)))
738 {
739 tTimeStamp nLastTime = pLastSample->GetTime();
740 while (oItems.size() > 1)
741 {
742 auto& oItem = oItems.front();
743 if (oItem.GetType() == IStreamItem::tType::Sample)
744 {
746 if (IS_OK(oItem.GetSample(pSample)))
747 {
748 if (nLastTime - pSample->GetTime() < TimeRange)
749 {
750 break;
751 }
752 }
753 }
754
755 PopFront();
756 }
757 }
758 }
759 }
760};
761
767template<typename INTERNAL_QUEUE,
768 bool STORE_LAST_SAMPLE = true,
770class sample_reader : public std::conditional<STORE_LAST_SAMPLE, cLastSampleReader, cSampleReader>::type
771{
772protected:
774 INTERNAL_QUEUE m_oInternalQueue;
775
777 typedef typename std::conditional<STORE_LAST_SAMPLE, cLastSampleReader, cSampleReader>::type base_class;
778
779public:
780 sample_reader(): base_class(ACCESS_MODE)
781 {
782 }
783
784 tResult Push(const IStreamItem& oItem, tTimeStamp tsTime) override
785 {
786 return m_oInternalQueue.Push(oItem, tsTime);
787 };
788
789 void Clear() override
790 {
791 m_oInternalQueue.Clear();
792 };
793
794 tResult Pop(IStreamItem& oItem) override
795 {
796 return m_oInternalQueue.Pop(oItem);
797 }
798};
799
808
818template<tTimeStamp TIME_RANGE, bool STORELASTSAMPLE = true>
820
830template<size_t MAX_SIZE, bool STORELASTSAMPLE = true>
832
838
848{
850 pSample.Reset(pEmpty);
851 oSampleReader.GetNextSample(pSample);
852 return oSampleReader;
853}
854
863template<typename DATATYPE>
865{
867 if (IS_OK(oSampleReader.GetNextSample(pSample)))
868 {
869 oSampleData.Reset(pSample);
870 }
871 else
872 {
873 oSampleData.Reset();
874 }
875 return oSampleReader;
876}
877
886{
887 oSampleReader.GetLastType(pType);
888 return oSampleReader;
889}
890
898inline cSampleReader& operator>>(cSampleReader& oSampleReader, cSampleReader& (*pStreamfunc)(cSampleReader&) )
899{
900 return pStreamfunc(oSampleReader);
901}
902
911 const char* strNameOfReader,
912 const ucom::iobject_ptr<const IStreamType>& pStreamType)
913{
914 oReader.SetName(strNameOfReader);
915 return oReader.SetType(pStreamType);
916}
917
924{
925public:
926 using cExternalQueueSampleReader::cExternalQueueSampleReader;
927
933 ADTF3_DEPRECATED("Please use 'cExternalQueueSampleReader' instead.")
937};
938
939} // namespace ant
940
941namespace flash
942{
943
948{
949public:
957 cSampleReader(ant::ISampleReaderQueue& oQueue, ant::ISampleStreamAccess::tMode eAccessMode, bool bStoreLastSample);
958
959 ~cSampleReader() override;
960
961 void SetName(const char* strName) override;
962 tResult GetName(base::ant::IString&& strName) override;
963
966
967 tResult BeginStreaming(ISampleStream& oSampleStream) override;
969
971
976 const std::function<tResult(const ucom::ant::iobject_ptr<const ant::IStreamType>& pStreamType)>&
977 fnAcceptTypeCallback);
978
982 void SetStreamErrorCallback(const std::function<tResult(tResult oStreamError)>& fnStreamErrorCallback);
984
987
989 void Reset();
990
992
997 uint32_t nSubStreamId,
998 const base::ant::IProperties* pRequestProperties = nullptr);
1005 const std::function<tResult(const ucom::ant::iobject_ptr<const ant::IStreamType>& pStreamType)>&
1006 fnRequestTypeUpdateCallback);
1007
1008protected:
1009 class cImplementation;
1010 std::unique_ptr<cImplementation> m_pImplementation;
1011};
1012
1023template<typename INTERNAL_QUEUE,
1024 bool STORE_LAST_SAMPLE = true,
1026class sample_reader : public cSampleReader
1027{
1028protected:
1029 INTERNAL_QUEUE m_oQueue;
1030
1031public:
1032 sample_reader(): cSampleReader(m_oQueue, ACCESS_MODE, STORE_LAST_SAMPLE)
1033 {
1034 }
1035};
1036
1038{
1039public:
1040 void RegisterExternalQueue(ISampleReaderQueue* pExternalBuffer)
1041 {
1042 m_oExternalQueues.insert(pExternalBuffer);
1043 }
1044
1045 void UnregisterExternalQueue(ISampleReaderQueue* pExternalBuffer)
1046 {
1047 m_oExternalQueues.erase(pExternalBuffer);
1048 }
1049
1050public:
1051 tResult Push(const IStreamItem& oStreamItem, tTimeStamp tsTime) override
1052 {
1053 for (auto pQueue : m_oExternalQueues)
1054 {
1055 RETURN_IF_FAILED(pQueue->Push(oStreamItem, tsTime));
1056 }
1057
1059 };
1060
1061 void Clear() override
1062 {
1063 for (auto pQueue : m_oExternalQueues)
1064 {
1065 pQueue->Clear();
1066 }
1067 }
1068
1069 tResult Pop(IStreamItem& /* oStreamItem */) override
1070 {
1071 RETURN_ERROR(ERR_EMPTY);
1072 }
1073
1074protected:
1076 std::set<ISampleReaderQueue*> m_oExternalQueues;
1077};
1078
1080{
1081protected:
1082 virtual ~IExternalReaderQueues() = default;
1083
1084public:
1085 virtual void RegisterExternalQueue(ISampleReaderQueue* pExternalBuffer) = 0;
1086 virtual void UnregisterExternalQueue(ISampleReaderQueue* pExternalBuffer) = 0;
1087};
1088
1089class cExternalQueueSampleReader : public sample_reader<cExternalQueuesWrapper, false>, public IExternalReaderQueues
1090{
1091public:
1092 void RegisterExternalQueue(ISampleReaderQueue* pExternalBuffer) override
1093 {
1094 m_oQueue.RegisterExternalQueue(pExternalBuffer);
1095 }
1096
1097 void UnregisterExternalQueue(ISampleReaderQueue* pExternalBuffer) override
1098 {
1099 m_oQueue.UnregisterExternalQueue(pExternalBuffer);
1100 }
1101};
1102
1108
1113template<tTimeStamp TIME_RANGE, bool STORELASTSAMPLE = true>
1115
1120template<size_t MAX_SIZE, bool STORELASTSAMPLE = true>
1122
1128
1129inline tResult make_sample_reader(ISampleReader& oReader,
1130 const char* strNameOfReader,
1131 const ucom::iobject_ptr<const IStreamType>& pStreamType)
1132{
1133 oReader.SetName(strNameOfReader);
1134 return oReader.SetType(pStreamType);
1135}
1136
1137inline ISampleReader& operator>>(ISampleReader& oSampleReader, ucom::ant::iobject_ptr<const ant::ISample>& pSample)
1138{
1140 pSample.Reset(pEmpty);
1141 oSampleReader.GetNextSample(pSample);
1142 return oSampleReader;
1143}
1144
1145template<typename DATATYPE>
1146ISampleReader& operator>>(ISampleReader& oSampleReader, sample_data<DATATYPE>& oSampleData)
1147{
1149 if (IS_OK(oSampleReader.GetNextSample(pSample)))
1150 {
1151 oSampleData.Reset(pSample);
1152 }
1153 else
1154 {
1155 oSampleData.Reset();
1156 }
1157 return oSampleReader;
1158}
1159
1160inline ISampleReader& operator>>(ISampleReader& oSampleReader, ucom::ant::iobject_ptr<const ant::IStreamType>& pType)
1161{
1162 oSampleReader.GetLastType(pType);
1163 return oSampleReader;
1164}
1165
1166inline ISampleReader& operator>>(ISampleReader& oSampleReader, ISampleReader& (*pStreamfunc)(ISampleReader&) )
1167{
1168 return pStreamfunc(oSampleReader);
1169}
1170
1171} // namespace flash
1172
1173namespace kiwi
1174{
1175
1180{
1181public:
1186
1190 ~cNullReader() override;
1191
1192 void SetName(const char* strName) override;
1199
1205
1206 void SetAcceptTypeCallback(
1207 const std::function<tResult(const ucom::ant::iobject_ptr<const ant::IStreamType>& pStreamType)>&
1208 fnAcceptTypeCallback);
1209 void SetStreamErrorCallback(const std::function<tResult(tResult oStreamError)>& fnStreamErrorCallback);
1210
1211protected:
1212 class cImplementation;
1213 std::unique_ptr<cImplementation> m_pImplementation;
1214};
1215
1216} // namespace kiwi
1217
1221
1230
1231using flash::make_sample_reader;
1232
1233using kiwi::cNullReader;
1234
1235} // namespace streaming
1236} // namespace adtf
#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: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
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 & 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
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
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)
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 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