ADTF  3.18.2
sample_intf.h
Go to the documentation of this file.
1 
7 #pragma once
8 #include "samplebuffer_intf.h"
9 #include "sampleinfo_intf.h"
11 
12 #include <adtfucom3/adtf_ucom3.h>
13 #include <adtfbase/chrono.h>
15 
16 namespace adtf
17 {
18 namespace streaming
19 {
20 namespace ant
21 {
22 
23 
25 #define CID_ADTF_SAMPLE_POOL "sample_pool.service.adtf.cid"
35 {
36  protected:
38  ~ISample() = default;
39 
40  public:
42  ADTF_IID(ISample, "sample.ant.streaming.adtf.iid");
43 
44 
45  public:
48  enum eFlags : uint32_t
49  {
51  SF_None = 0x0,
52 
59  SF_SyncPoint = 0x2,
60 
65 
70 
73 
83  };
84 
98 
99 
118  size_t szPreAllocateSize) = 0;
119 
126  virtual tResult Set(const ISample& oSample) = 0;
127 
134  virtual tResult Get(ISample& oSample) const = 0;
135 
141  virtual tResult Reset() = 0;
142 
150  virtual uint32_t GetFlags() const = 0;
151 
161  virtual tResult SetFlags(uint32_t ui32Flags) = 0;
162 
183  virtual tResult Set(tTimeStamp tmTimeStamp,
184  const void* pData,
185  size_t szSize,
186  uint32_t ui32Flags=0) = 0;
195 
202 
209 
215 
225  virtual tTimeStamp GetTime() const = 0;
226 
238  virtual tResult SetTime(tTimeStamp tmTimeStamp) = 0;
239 };
240 
255 template<typename T>
256 tResult read_from_sample(const ISample& oSample, T& oValue)
257 {
259  RETURN_IF_FAILED(oSample.Lock(pSampleBuffer));
260  return pSampleBuffer->Read(adtf::base::adtf_memory<void, sizeof(oValue)>(&oValue));
261 }
262 
277 template<typename T>
278 tResult write_to_sample(ISample& oSample, const T& oValue)
279 {
280  static_assert(std::is_trivially_copyable<T>::value, "The data type needs to be trivially copyable.");
282  RETURN_IF_FAILED(oSample.WriteLock(pSampleBuffer, sizeof(oValue)));
283  return pSampleBuffer->Write(adtf::base::adtf_memory<const void, sizeof(oValue)>(&oValue));
284 }
285 
286 } //namespace ant
287 
288 namespace flash
289 {
290 
294 class ISample: public ant::ISample
295 {
296  protected:
298  ~ISample() = default;
299 
300  public:
302  ADTF_IID(ISample, "sample.flash.streaming.adtf.iid");
303 
304  public:
305  using ant::ISample::SetTime;
306  using ant::ISample::Set;
307 
310 
312  virtual tResult SetTime(base::flash::tNanoSeconds tmTimeStamp) = 0;
313 
334  virtual tResult Set(base::flash::tNanoSeconds tmTimeStamp,
335  const void* pData,
336  size_t szSize,
337  uint32_t ui32Flags=0) = 0;
338 
339 };
340 
341 }
342 
343 namespace hollow
344 {
345 
349 class ISample: public flash::ISample
350 {
351  protected:
353  ~ISample() = default;
354 
355  public:
357  ADTF_IID(ISample, "sample.hollow.streaming.adtf.iid");
358 
359  public:
363  virtual uint32_t GetSubStreamId() const = 0;
364 
369  virtual void SetSubStreamId(uint32_t nSubStreamId) = 0;
370 };
371 
372 }
373 
374 // we keep ant::ISample as default, as this is what the streaming architecture and interfaces are able to transport.
375 using ant::ISample;
378 
379 } //namespace streaming
380 } // namespace adtf
Copyright © Audi Electronics Venture GmbH.
#define RETURN_IF_FAILED(s)
Return if expression is failed, which requires the calling function's return type to be tResult.
Copyright © Audi Electronics Venture GmbH.
Template class implementation for the ant::IRawMemory interface (see Supported types for adtf_memory<...
The ISample interface sets and retrieves properties on samples .
Definition: sample_intf.h:35
virtual tTimeStamp GetTime() const =0
Retrieves the SampleTimeS (of StreamTime) of this sample.
virtual tResult SetTime(tTimeStamp tmTimeStamp)=0
Sets the SampleTimeStamp (of StreamTime).
virtual tResult Set(tTimeStamp tmTimeStamp, const void *pData, size_t szSize, uint32_t ui32Flags=0)=0
Sets the internal sample data and timestamp.
virtual tResult WriteLock(ucom::ant::iobject_ptr_locked< ISampleBuffer > &pSampleBuffer, size_t szPreAllocateSize)=0
Obtains a valid reference to the sample buffer for writing access.
virtual tResult SetFlags(uint32_t ui32Flags)=0
Specify sample flags.
virtual uint32_t GetFlags() const =0
Query sample flags.
eFlags
serval flags are defined All undefined bits are reserved for future and internal use.
Definition: sample_intf.h:49
@ SF_SyncPoint
Determines if the sample marks a synchronization point.
Definition: sample_intf.h:59
@ SF_VideoKeyFrame
This flag marks key frames in video streams.
Definition: sample_intf.h:72
@ SF_AbsoluteTime
This flag has no effect and is only remaining due to code and binary compatibility purpose!
Definition: sample_intf.h:64
@ SF_DataFromADTF1
If old ADTF V1.x data is stored, this flag will be set.
Definition: sample_intf.h:69
@ SF_SampleInfoPresent
This flag marks the sample has the SampleInfo present.
Definition: sample_intf.h:80
@ SF_SampleLogPresent
This flag marks the sample supports the ISampleLog interface and a trace is present from Deserializat...
Definition: sample_intf.h:78
@ SF_None
No flags are set.
Definition: sample_intf.h:51
@ SF_SampleLogEnabled
This flag marks that sample supports ISampleLog interface and it is enabled.
Definition: sample_intf.h:75
@ SF_AllowBufferSharing
mark that the buffer of this sample can be shared
Definition: sample_intf.h:82
virtual tResult Reset()=0
Resets the whole sample content.
ADTF_IID(ISample, "sample.ant.streaming.adtf.iid")
definition of interface id
virtual tResult GetSampleLog(ucom::ant::iobject_ptr< ISampleLog > &oSampleLog) const =0
Gets the ISampleLog of the sample.
virtual tResult Set(const ISample &oSample)=0
Deep copy the given sample (source) to this sample (destination).
virtual tResult Lock(ucom::ant::iobject_ptr_shared_locked< const ISampleBuffer > &oSampleBuffer) const =0
Obtains a valid read-only reference to the sample buffer.
virtual tResult GetSampleInfo(ucom::ant::iobject_ptr< const ISampleInfo > &oSampleInfo) const =0
Gets the ISampleInfo of the sample.
virtual tResult Get(ISample &oSample) const =0
Deep copy this sample (source) to the given sample (destination).
virtual tResult GetSampleInfo(ucom::ant::iobject_ptr< ISampleInfo > &oSampleInfo)=0
Gets the ISampleInfo of the sample.
~ISample()=default
not destructable
virtual tResult GetSampleBufferFactory(ucom::ant::iobject_ptr< ISampleBufferFactory > &oFactory) const =0
Gets the SampleBufferFactory the Sample will ask for SampleBuffer to allocate.
The ISample interface sets and retrieves properties on samples .
Definition: sample_intf.h:295
ADTF_IID(ISample, "sample.flash.streaming.adtf.iid")
definition of interface id
virtual tResult Set(base::flash::tNanoSeconds tmTimeStamp, const void *pData, size_t szSize, uint32_t ui32Flags=0)=0
Sets the internal sample data and timestamp.
virtual tResult SetTime(base::flash::tNanoSeconds tmTimeStamp)=0
Sets the SampleTimeStamp (of StreamTime).
virtual base::flash::tNanoSeconds GetTimeNs() const =0
Retrieves the SampleTimeS (of StreamTime) of this sample.
~ISample()=default
not destructable
The ISample interface sets and retrieves properties on samples .
Definition: sample_intf.h:350
ADTF_IID(ISample, "sample.hollow.streaming.adtf.iid")
definition of interface id
virtual uint32_t GetSubStreamId() const =0
~ISample()=default
not destructable
virtual void SetSubStreamId(uint32_t nSubStreamId)=0
Sets the id of the stream that the sample belongs to.
Base class for every interface type within the uCOM.
Definition: object_intf.h:31
Interfaces for a guarded exclusive lock.
Interfaces for a guarded shared lock.
Base object pointer to realize binary compatible reference counting in interface methods.
Implementation for a exclusive lock guard.
Implementation for a shared lock guard.
tResult write_to_sample(ISample &oSample, const T &oValue)
Helper to write the value oValue to the sample oSample.
Definition: sample_intf.h:278
tResult read_from_sample(const ISample &oSample, T &oValue)
Helper to read the value oValue from the sample oSample.
Definition: sample_intf.h:256
Namespace for entire ADTF SDK.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.