ADTF  3.18.2
legacy_streaming_sink.h
Go to the documentation of this file.
1 
7 #ifndef _ADTF_ADTF2_LEGACY_STREAMING_SINK_HEADER_
8 #define _ADTF_ADTF2_LEGACY_STREAMING_SINK_HEADER_
9 
10 namespace adtf
11 {
12 namespace adtf2
13 {
14 namespace ant
15 {
16 
19 
28  public cKernelAndClockHelper,
29  public cConfigurationHelper<cLegacyStreamingSink>,
30  public cLegacyPinEvents,
31  public cLegacyStateHandler,
32  public trigger_runnable
33 {
34  public:
40  m_pRunner(adtf::ucom::make_object_ptr<cTriggerPipeItemHelper>(*this))
41  {
42  }
43 
44  protected:
49  virtual tResult Construct()
50  {
51  RETURN_IF_FAILED(Init(cLegacyStateHandler::StageFirst));
52  return Init(cLegacyStateHandler::StageNormal);
53  }
54 
59  virtual tResult Destruct()
60  {
61  RETURN_IF_FAILED(Shutdown(cLegacyStateHandler::StageNormal));
62  return Shutdown(cLegacyStateHandler::StageFirst);
63  }
64 
69  virtual tResult Init()
70  {
71  return Init(cLegacyStateHandler::StageGraphReady);
72  }
73 
78  virtual tResult Shutdown()
79  {
80  return Shutdown(cLegacyStateHandler::StageGraphReady);
81  }
82 
88  {
89  return Start();
90  }
91 
97  {
98  return Stop();
99  }
100 
101  protected:
102  // these methods are defined here as well in order to allow easy access via
103  // cLegacyStreamingSource:: prefix.
104 
108  tResult Init(tInitStage /* eStage */) override
109  {
111  }
112 
116  tResult Start() override
117  {
119  }
120 
124  tResult Stop() override
125  {
127  }
128 
132  tResult Shutdown(tInitStage /* eStage */) override
133  {
135  }
136 
137  protected:
145  {
146  oInput.SetAcceptTypeCallback([&](const adtf::ucom::iobject_ptr<const adtf::streaming::IStreamType>& pStreamType)
147  {
148  return OnTypeChanged(&oInput, pStreamType);
149  });
150 
151  adtf_util::cString strNameOfReaderAndPin;
152  RETURN_IF_FAILED(oInput.GetName(adtf_string_intf(strNameOfReaderAndPin)));
153  auto pInPin = adtf::ucom::make_object_ptr<adtf::streaming::ant::cInPin>(strNameOfReaderAndPin);
154  oInput.ResetPin(pInPin);
156 
157  RETURN_IF_FAILED(pPin->RegisterSubItem(m_pRunner, adtf::streaming::ITriggerPipeSource::Normal));
158  RETURN_IF_FAILED(cSampleStreamingSink::RegisterPin(pPin));
159  m_oLegacyPins.push_back(&oInput);
161  }
162 
168  tResult Trigger(tTimeStamp /* tmTimeOfActivation */)
169  {
170  bool bSamplesFound;
171  do
172  {
173  bSamplesFound = false;
174  for (auto& pReader: m_oLegacyPins)
175  {
177  if (IS_OK(pReader->GetNextSample(pSample)))
178  {
180  pSample));
181  bSamplesFound = true;
182  }
183  }
184  }
185  while (bSamplesFound);
186 
188  }
189 
190  private:
191  // we cannot make cLegacyStreamingSink a trigger pipe item itself,
192  // as this would cause a reference loop between the pins and the sink
195  public streaming::trigger_pipe_item<adtf::streaming::ITriggerPipeItem>
196  {
197  public:
200  {
201  SetRunnable(oSink);
202  }
203  };
204 
205  private:
209  std::vector<cLegacyInputPin*> m_oLegacyPins;
210 
211 
212 };
213 
214 }
215 
217 
218 }
219 }
220 
221 
222 #endif
#define RETURN_IF_FAILED(s)
Return if expression is failed, which requires the calling function's return type to be tResult.
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
Common base class for all legacy filter classes that emulates the old configuration interface.
Common base class for all legacy filter classes.
This class helps when porting ADTF 2 Filters to ADTF 3.
Definition: legacy_filter.h:27
Common base class for all legacy filter classes that emulates the old IPinEventHandler interface.
virtual tResult OnSampleReceived(cLegacyInputPin *, const adtf::ucom::iobject_ptr< const adtf::streaming::ISample > &)
This is called whenever a sample is received via one of the input Pins.
virtual tResult OnTypeChanged(cLegacyInputPin *pPin, const adtf::ucom::iobject_ptr< const adtf::streaming::IStreamType > &pType)
This is called whenever a type has been changed/received on one of the input Pins.
Common base class for all legacy filter classes that emulates the old state maschine of cFilter.
Class that helps with porting old ADTF 2 Filters to ADTF 3.
tResult Shutdown(tInitStage) override
Emulates the old Shutdown method.
tResult Init(tInitStage) override
Emulates the old Init method.
tResult Trigger(tTimeStamp)
Used internally to recreate the trogger scheme from ADTF2.
virtual tResult StopStreaming()
Used internally.
virtual tResult Construct()
Used internally.
tResult RegisterPin(cLegacyInputPin &oInput)
Compatibility method to register Pins.
virtual tResult StartStreaming()
Used internally.
virtual tResult Shutdown()
Used internally.
tResult Stop() override
Emulates the old Stop method.
tResult Start() override
Emulates the old Start method.
virtual tResult Init()
Used internally.
virtual tResult Destruct()
Used internally.
Default implementation class template for a ITriggerPipeItem.
Definition: triggerpipe.h:155
void SetRunnable(adtf::base::ant::IRunnable &oRunnable)
Sets the Runnable implementation to call if Run is called.
Definition: triggerpipe.h:225
Basic implementation for a Streaming Sink.
Base object pointer to realize binary compatible reference counting in interface methods.
Object pointer implementation used for reference counting on objects of type IObject.
Definition: object_ptr.h:163
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
std::enable_if< !std::is_base_of< enable_object_ptr_from_this< typename std::remove_cv< Implementation >::type >, typename std::remove_cv< Implementation >::type >::value, object_ptr< Implementation > >::type make_object_ptr(Args &&... args)
Create an instance of type object_ptr with Implementation as the shared resource.
Namespace for entire ADTF SDK.
#define ADTF_RUN_FUNCTION(_fcName_)
Helper Macro to define Run function for adtf::base::ant::runnable<>
Definition: runnable.h:196
#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