ADTF
|
The default Sample Reader will read the incomung Stream of a IInPin. More...
Public Member Functions | |
cSampleReader () | |
Default CTOR. | |
cSampleReader (ISampleStreamAccess::tMode eAccessMode) | |
Default CTOR which defines the access method. More... | |
virtual tResult | AcceptType (const ucom::ant::iobject_ptr< const IStreamType > &pStreamType) |
Accept or reject a new stream type - see also AcceptType and IsCompatible implementations. More... | |
tResult | BeginStreaming (ISampleStream &oSampleStream) override |
BeginStreaming will open the given Sample Stream for Reading while a connection is establishing. More... | |
tResult | EndStreaming () override |
Sample Stream disconnected. More... | |
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 - see also AcceptType and IsCompatible implementations. More... | |
void | SetStreamErrorCallback (const std::function< tResult(tResult oStreamError)> &fnStreamErrorCallback) |
A callback function to react on stream errors. More... | |
tResult | SetStreamError (const tResult &oError) |
Forward an error to the corresponding stream. More... | |
void | GetSampleInStream (ucom::ant::iobject_ptr< ISampleInStream > &pSampleInStream) |
Returns the connected ISampleInStream. | |
void | GetLastType (ucom::ant::iobject_ptr< const IStreamType > &pType) |
Returns the connected ISampleInStream. | |
virtual tResult | GetNextSample (ucom::ant::iobject_ptr< const ISample > &pSample) |
Gets the next Sample within internal queue which not has been read. More... | |
void | Reset () override |
virtual tResult | Push (const IStreamItem &oStreamItem, tTimeStamp tmTime)=0 |
Push a new value to the internal sample queue. More... | |
virtual void | Clear ()=0 |
clears the local queue of the reader either only EndStreaming or incoming event ISampleInStream::IQueueItem::RE_Flush | |
virtual tResult | Pop (IStreamItem &oStreamItem)=0 |
Returns the next sample from the queue. More... | |
Public Member Functions inherited from sample_streamer< ISampleReader, cInPin > | |
sample_streamer ()=default | |
CTOR. | |
sample_streamer (const char *strName, const ucom::ant::iobject_ptr< const IStreamType > &pStreamType) | |
CTOR initializer. More... | |
virtual | ~sample_streamer () |
DTOR. | |
void | SetName (const char *strName) |
Sets the name of the streamer. More... | |
void | ResetPin (ucom::ant::object_ptr< cInPin > &pPin) |
Resets the pin reference This is only internaly used. More... | |
void | ResetPin () |
Resets the pin reference to nullptr. More... | |
tResult | GetName (base::ant::IString &&strName) const |
Gets the name of the streamer. More... | |
tResult | SetType (const ucom::ant::iobject_ptr< const IStreamType > &pStreamType) |
Sets the StreamType of the streamer. More... | |
tResult | GetType (ucom::ant::iobject_ptr< const IStreamType > &pStreamType) const override |
tResult | EndStreaming () override |
Public Member Functions inherited from ISampleReaderQueue | |
virtual tResult | Push (const IStreamItem &oStreamItem, tTimeStamp tmTime)=0 |
Push a new value to the internal sample queue. More... | |
virtual tResult | Pop (IStreamItem &oStreamItem)=0 |
Returns the next sample from the queue. More... | |
Public Member Functions inherited from runnable< base::ant::IRunnable::RUN_PUSH, ISampleStream::IPushReadEventSink > | |
runnable () | |
CTOR. | |
runnable (IRunnable::tRunFunction fcRunOnceFunc) | |
Main CTOR with callable function. More... | |
virtual | ~runnable ()=default |
DTOR. | |
tResult | Run (tTimeStamp tmTimeofActivation, IRunnable::tActivationType ui32ActivationType, const void *, size_t) override |
IRunnable::Run implementation which will call m_fcRunOnceFunc if ui32ActivationType is TYPE_OF_ACTIVATION . More... | |
virtual IRunnable::tActivationType | GetActivationType () const |
Returns the type of activation implemented. More... | |
Public Member Functions inherited from object< Bases > | |
tResult | GetInterface (const char *i_strIID, void *&o_pInterface) override |
Query interfaces on an object. More... | |
tResult | GetInterface (const char *i_strIID, const void *&o_pInterface) const override |
Provides const correct interface querying. More... | |
void | Destroy () const override |
Destruct and deallocate instantiations of type IObject . More... | |
Public Member Functions inherited from IObject | |
ADTF_IID (IObject, "object.ant.ucom.adtf.iid") | |
Marks the IObject to be castable with the ucom_cast() More... | |
Protected Member Functions | |
tResult | Push (tTimeStamp tmTimeofActivation) |
internal Push operation to implement pushread mode | |
virtual tResult | ReadNextSample (ucom::ant::iobject_ptr< const ISample > &pSample) |
This will read the stream items until a sample is reached and return it. More... | |
tResult | ProcessStreamItem (const IStreamItem &oStreamItem) |
This will process the stream items. More... | |
tResult | HandleStreamError (tResult nError) |
Protected Member Functions inherited from sample_streamer< ISampleReader, cInPin > | |
sample_streamer (const sample_streamer &)=delete | |
deleted copy CTOR | |
sample_streamer (sample_streamer &&)=delete | |
deleted move CTOR | |
sample_streamer & | operator= (const sample_streamer &)=delete |
deleted copy operator | |
sample_streamer & | operator= (sample_streamer &&)=delete |
deleted move operator | |
Protected Member Functions inherited from ISampleReader | |
~ISampleReader ()=default | |
not destructable | |
Protected Member Functions inherited from ISampleStreamer | |
~ISampleStreamer ()=default | |
not destructable | |
Protected Member Functions inherited from IObject | |
~IObject ()=default | |
Protected destructor --> Use implemented Destroy() instead of delete! | |
Private Types | |
typedef sample_streamer< ISampleReader, cInPin > | base_type |
base type of cSampleReader | |
typedef base::ant::runnable< base::ant::IRunnable::RUN_PUSH, ISampleStream::IPushReadEventSink > | runnable_type |
internal base type. | |
Private Attributes | |
ucom::object_ptr< ISampleInStream > | m_pInStream |
Reader where to read. | |
std::mutex | m_oReadLock |
Read synchronization. | |
std::function< tResult(const ucom::iobject_ptr< const IStreamType > &pStreamType)> | m_fnAcceptTypeCallback |
Callback to reject type changes. | |
std::function< tResult(tResult oStreamError)> | m_fnStreamErrorCallback |
Callback to react on stream errors. | |
bool | m_bValidType = true |
state wether the current type is a valid type or not this will be set to false in AcceptType fails. | |
ucom::object_ptr< const IStreamType > | m_pLastReadStreamType |
Last accepted incoming type. | |
ISampleStreamAccess::tMode | m_eAccessMode |
current access method | |
Additional Inherited Members | |
Public Types inherited from sample_streamer< ISampleReader, cInPin > | |
typedef cInPin | pin_type |
Protected Attributes inherited from sample_streamer< ISampleReader, cInPin > | |
adtf_util::cString | m_strName |
name of the streamer (used i.e. to create the pins name) | |
ucom::object_ptr< const IStreamType > | m_pStreamType |
stream type of the streamer | |
ucom::object_ptr< cInPin > | m_poPin |
pin reference reading/writing from | |
Protected Attributes inherited from runnable< base::ant::IRunnable::RUN_PUSH, ISampleStream::IPushReadEventSink > | |
IRunnable::tRunFunction | m_fcRunOnceFunc |
given function to call on Run | |
The default Sample Reader will read the incomung Stream of a IInPin.
This sample reader has no internal queue! Make sure if you use this sample reader with ISampleStreamAccess::PushRead to register a external queue or to override the adtf::streaming::ant::cSampleReader::Push, cSampleReader::ReadNextSample and cSampleReader::Push methods (for more detail see sample_reader)
Definition at line 171 of file samplereader.h.
|
inline |
Default CTOR which defines the access method.
eAccessMode | the access method. |
Definition at line 220 of file samplereader.h.
|
virtual |
Accept or reject a new stream type - see also AcceptType and IsCompatible implementations.
If the cSampleReader::SetAcceptTypeCallback method was used to set a accept sample callback method the internal meta type comparison will be replaced. The internal meta type comparison uses the IStreamMetaType::IsCompatible implementation, where the "old" type and its Stream Meta Type decides wether the incoming type is accepted or rejected.
[in] | pStreamType | The incoming Stream Type to accept or reject. |
ERR_INVALID_TYPE | the incoming Stream Type is not valid |
ERR_NOERROR | the incoming Stream Type is valid |
Referenced by cSampleReader::ProcessStreamItem().
|
inlineoverridevirtual |
BeginStreaming will open the given Sample Stream for Reading while a connection is establishing.
pStream | [in] Sample Stream to open |
Implements ISampleReader.
Definition at line 244 of file samplereader.h.
References cSampleReader::EndStreaming(), cSampleReader::m_eAccessMode, cSampleReader::m_oReadLock, cSampleReader::m_pInStream, sample_streamer< ISampleReader, cInPin >::m_pStreamType, sample_streamer< ISampleReader, cInPin >::m_strName, ISampleStream::Open(), RETURN_ERROR_DESC, RETURN_IF_FAILED, and RETURN_NOERROR.
|
inlineoverridevirtual |
Sample Stream disconnected.
Streaming ends.
Implements ISampleStreamer.
Definition at line 270 of file samplereader.h.
References cSampleReader::Clear(), cSampleReader::m_oReadLock, cSampleReader::m_pInStream, and RETURN_NOERROR.
Referenced by cSampleReader::BeginStreaming().
|
inlinevirtual |
Gets the next Sample within internal queue which not has been read.
param[out] pSample Sample found
ERR_EMPTY | No Sample found. |
Definition at line 346 of file samplereader.h.
References cSampleReader::ReadNextSample().
Referenced by adtf::streaming::ant::operator>>().
virtual tResult Pop |
Returns the next sample from the queue.
[out] | oStreamItem | stream item reference to copy the references to |
Referenced by cSampleReader::ReadNextSample().
|
inlineprotected |
This will process the stream items.
This method will cal the user hook callbacks for accepting type (cSampleReader::SetAcceptTypeCallback)
oStreamItem | Recently read stream item. |
ERR_INVALID_TYPE | received Stream Type and Stream Meta Type was not accepted. |
ERR_NOT_CONNECTED | No Sample Stream is connected and the cSampleReader::BeginStreaming is not called yet. |
Definition at line 434 of file samplereader.h.
References cSampleReader::AcceptType(), ADTF_BASE_COMPOSED_RESULT, IStreamItem::GetStreamType(), IStreamItem::GetType(), IS_FAILED, cSampleReader::m_bValidType, RETURN_ERROR, RETURN_IF_FAILED, RETURN_NOERROR, and IStreamItem::StreamType.
Referenced by cSampleReader::ReadNextSample().
virtual tResult Push |
Push a new value to the internal sample queue.
[in] | oStreamItem | The sample to store |
[in] | tmTime | Time of storage |
Referenced by cSampleReader::Push().
|
inlineprotectedvirtual |
This will read the stream items until a sample is reached and return it.
If another stream item type is reached than sample, cSampleReader::ProcessStreamItem will handle it.
pSample | sample reference set if valid. |
ERR_EMPTY | stream is empty |
ERR_INVALID_TYPE | received Stream Type and Stream Meta Type was not accepted. |
ERR_NOT_CONNECTED | No Sample Stream is connected and the cSampleReader::BeginStreaming is not called yet. |
Reimplemented in cLastSampleReader.
Definition at line 394 of file samplereader.h.
References ISampleStreamAccess::AsyncQueue, cStreamItem::GetSample(), cStreamItem::GetType(), IS_OK, cSampleReader::m_pInStream, cSampleReader::Pop(), cSampleReader::ProcessStreamItem(), RETURN_IF_FAILED, and IStreamItem::Sample.
Referenced by cSampleReader::GetNextSample(), and cLastSampleReader::ReadNextSample().
|
inline |
Sets a callback function which is called while a Stream Type is received - see also AcceptType and IsCompatible implementations.
[in] | fnAcceptTypeCallback | The callback function is called while AcceptType is executed. It must return ERR_NOERROR to accept the type or any error to reject the new type. |
Definition at line 288 of file samplereader.h.
Forward an error to the corresponding stream.
oError | [in] The error passed to the SampleStream. |
Definition at line 305 of file samplereader.h.
References cSampleReader::m_oReadLock, cSampleReader::m_pInStream, and RETURN_ERROR.
|
inline |
A callback function to react on stream errors.
[in] | fnStreamErrorCallback | The callback function which will be called on stream errors |
Definition at line 298 of file samplereader.h.
References cSampleReader::m_fnStreamErrorCallback.