ADTF
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 #include <adtf_base_deprecated.h>
16 
17 namespace adtf
18 {
19 namespace streaming
20 {
21 namespace ant
22 {
23 
24 
26 #define CID_ADTF_SAMPLE_POOL "sample_pool.service.adtf.cid"
36 {
37  protected:
39  ~ISample() = default;
40 
41  public:
43  ADTF_IID(ISample, "sample.ant.streaming.adtf.iid");
44 
45 
46  public:
49  enum eFlags : uint32_t
50  {
52  SF_None = 0x0,
53 
60  SF_SyncPoint = 0x2,
61 
66 
71 
74 
84  };
85 
99 
100 
119  size_t szPreAllocateSize) = 0;
120 
127  virtual tResult Set(const ISample& oSample) = 0;
128 
135  virtual tResult Get(ISample& oSample) const = 0;
136 
142  virtual tResult Reset() = 0;
143 
151  virtual uint32_t GetFlags() const = 0;
152 
162  virtual tResult SetFlags(uint32_t ui32Flags) = 0;
163 
185  ADTF3_DEPRECATED("Use adtf::streaming::flash::ISample::Set(adtf::base::flash::tNanoSeconds tmTimeStamp, const void* pData, size_t szSize, uint32_t ui32Flags=0) instead.")
186  virtual tResult Set(tTimeStamp tmTimeStamp,
187  const void* pData,
188  size_t szSize,
189  uint32_t ui32Flags=0) = 0;
197  virtual tResult GetSampleBufferFactory(ucom::ant::iobject_ptr<ISampleBufferFactory>& oFactory) const = 0;
198 
204  virtual tResult GetSampleInfo(ucom::ant::iobject_ptr<const ISampleInfo>& oSampleInfo) const = 0;
205 
211  virtual tResult GetSampleInfo(ucom::ant::iobject_ptr<ISampleInfo>& oSampleInfo) = 0;
212 
217  virtual tResult GetSampleLog(ucom::ant::iobject_ptr<ISampleLog>& oSampleLog) const = 0;
218 
228  ADTF3_DEPRECATED("Use adtf::streaming::flash::ISample::GetTimeNs() instead.")
229  virtual tTimeStamp GetTime() const = 0;
230 
242  ADTF3_DEPRECATED("Use adtf::streaming::flash::ISample::SetTime(adtf::base::flash::tNanoSeconds tmTimeStamp) instead.")
243  virtual tResult SetTime(tTimeStamp tmTimeStamp) = 0;
244 };
245 
260 template<typename T>
261 tResult read_from_sample(const ISample& oSample, T& oValue)
262 {
264  RETURN_IF_FAILED(oSample.Lock(pSampleBuffer));
265  return pSampleBuffer->Read(adtf::base::adtf_memory<void, sizeof(oValue)>(&oValue));
266 }
267 
282 template<typename T>
283 tResult write_to_sample(ISample& oSample, const T& oValue)
284 {
285  static_assert(std::is_trivially_copyable<T>::value, "The data type needs to be trivially copyable.");
287  RETURN_IF_FAILED(oSample.WriteLock(pSampleBuffer, sizeof(oValue)));
288  return pSampleBuffer->Write(adtf::base::adtf_memory<const void, sizeof(oValue)>(&oValue));
289 }
290 
291 } //namespace ant
292 
293 namespace flash
294 {
295 
299 class ISample: public ant::ISample
300 {
301  protected:
303  ~ISample() = default;
304 
305  public:
307  ADTF_IID(ISample, "sample.flash.streaming.adtf.iid");
308 
309  public:
310  using ant::ISample::SetTime;
311  using ant::ISample::Set;
312 
322 
334  virtual tResult SetTime(base::flash::tNanoSeconds tmTimeStamp) = 0;
335 
356  virtual tResult Set(base::flash::tNanoSeconds tmTimeStamp,
357  const void* pData,
358  size_t szSize,
359  uint32_t ui32Flags=0) = 0;
360 
361 };
362 
363 }
364 
365 namespace hollow
366 {
367 
371 class ISample: public flash::ISample
372 {
373  protected:
375  ~ISample() = default;
376 
377  public:
379  ADTF_IID(ISample, "sample.hollow.streaming.adtf.iid");
380 
381  public:
385  virtual uint32_t GetSubStreamId() const = 0;
386 
391  virtual void SetSubStreamId(uint32_t nSubStreamId) = 0;
392 };
393 
394 }
395 
396 namespace thor
397 {
398 
403 {
404  protected:
406  ~ISample() = default;
407 
408  public:
410  ADTF_IID(ISample, "sample.thor.streaming.adtf.iid");
411 
412  public:
413  using hollow::ISample::Set;
414 
423  virtual tResult Set(const ant::ISample& oSample, size_t nOffset, size_t nSize) = 0;
424 
432 };
433 
434 }
435 
436 // we keep ant::ISample as default, as this is what the streaming architecture and interfaces are able to transport.
437 using ant::ISample;
440 
441 } //namespace streaming
442 } // namespace adtf
Copyright © Audi Electronics Venture GmbH.
#define ADTF3_DEPRECATED(_depr_message_)
Mark a function or variable as deprecated.
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 SampleBuffer factory manages and can create SampleBuffers.
The ISample interface sets and retrieves properties on samples .
Definition: sample_intf.h:36
virtual tTimeStamp GetTime() const =0
Retrieves the sample timestamp (of stream time) of this sample.
virtual tResult SetTime(tTimeStamp tmTimeStamp)=0
Sets the sample timestamp (of stream time).
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:50
@ SF_SyncPoint
Determines if the sample marks a synchronization point.
Definition: sample_intf.h:60
@ SF_VideoKeyFrame
This flag marks key frames in video streams.
Definition: sample_intf.h:73
@ SF_AbsoluteTime
This flag has no effect and is only remaining due to code and binary compatibility purpose!
Definition: sample_intf.h:65
@ SF_DataFromADTF1
If old ADTF V1.x data is stored, this flag will be set.
Definition: sample_intf.h:70
@ SF_SampleInfoPresent
This flag marks the sample has the SampleInfo present.
Definition: sample_intf.h:81
@ SF_SampleLogPresent
This flag marks the sample supports the ISampleLog interface and a trace is present from Deserializat...
Definition: sample_intf.h:79
@ SF_None
No flags are set.
Definition: sample_intf.h:52
@ SF_SampleLogEnabled
This flag marks that sample supports ISampleLog interface and it is enabled.
Definition: sample_intf.h:76
@ SF_AllowBufferSharing
mark that the buffer of this sample can be shared
Definition: sample_intf.h:83
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).
~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.
Interface for additional sample information on a Additional Sample Information.
The ISampleLog interface defines an interface to trace and store Sample data- and timing flow.
The ISample interface sets and retrieves properties on samples .
Definition: sample_intf.h:300
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 sample timestamp (of stream time).
virtual base::flash::tNanoSeconds GetTimeNs() const =0
Retrieves the sample timestamp (of stream time) of this sample.
~ISample()=default
not destructable
The ISample interface sets and retrieves properties on samples .
Definition: sample_intf.h:372
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.
The ISample interface sets and retrieves properties on samples .
Definition: sample_intf.h:403
virtual tResult Set(const ant::ISample &oSample, size_t nOffset, size_t nSize)=0
Copies all meta data from a source sample and references a sub section of the source sample buffer.
ADTF_IID(ISample, "sample.thor.streaming.adtf.iid")
definition of interface id
~ISample()=default
not destructable
virtual tResult SetSampleBuffer(const ucom::ant::iobject_ptr< const ISampleBuffer > &pBuffer)=0
Attaches the given sample buffer to the sample.
Base class for every interface type within the uCOM.
Definition: object_intf.h:33
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:283
tResult read_from_sample(const ISample &oSample, T &oValue)
Helper to read the value oValue from the sample oSample.
Definition: sample_intf.h:261
ant::iobject_ptr< T > iobject_ptr
Alias always bringing the latest version of ant::iobject_ptr into scope.
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.