You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

BoxAlgorithmProxy.h 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. //
  2. //
  3. #pragma once
  4. #include <string>
  5. #include <vector>
  6. #include <openvibe/ov_all.h>
  7. #include <toolkit/ovtk_all.h>
  8. #include <system/ovCTime.h>
  9. #include "Contexted.h"
  10. namespace OpenViBE {
  11. namespace Kernel {
  12. /**
  13. * \class IBoxIOProxy
  14. * \brief This proxy is intended for reusing codecs from the toolkit.
  15. * @fixme it'd be more elegant not to duplicate this interface as a very similar one is already implemented in BoxAdapterHelper.
  16. * however unifying the two would need some work.
  17. * \author J. T. Lindgren
  18. *
  19. */
  20. class OV_API_Export IBoxIOProxy final : public IBoxIO
  21. {
  22. public:
  23. size_t getInputChunkCount(const size_t /*index*/) const override { return 0; }
  24. bool getInputChunk(const size_t /*inputIdx*/, const size_t /*chunkIdx*/, uint64_t& /*startTime*/, uint64_t& /*endTime*/, size_t& /*chunkSize*/,
  25. const uint8_t*& /*chunkBuffer*/) const override { return true; }
  26. const IMemoryBuffer* getInputChunk(const size_t /*inputIdx*/, const size_t /*chunkIdx*/) const override { return &m_InBuffer; }
  27. uint64_t getInputChunkStartTime(const size_t /*inputIdx*/, const size_t /*chunkIdx*/) const override { return 0; }
  28. uint64_t getInputChunkEndTime(const size_t /*inputIdx*/, const size_t /*chunkIdx*/) const override { return 0; }
  29. bool markInputAsDeprecated(const size_t /*inputIdx*/, const size_t /*chunkIdx*/) override { return true; }
  30. size_t getOutputChunkSize(const size_t /*index*/) const override { return m_OutBuffer.getSize(); }
  31. bool setOutputChunkSize(const size_t /*index*/, const size_t size, const bool /*discard*/ = true) override { return m_OutBuffer.setSize(size, true); }
  32. uint8_t* getOutputChunkBuffer(const size_t /*index*/) override { return m_OutBuffer.getDirectPointer(); }
  33. bool appendOutputChunkData(const size_t /*index*/, const uint8_t* /*buffer*/, const size_t /*size*/) override { return false; } // not implemented
  34. IMemoryBuffer* getOutputChunk(const size_t /*outputIdx*/) override { return &m_OutBuffer; }
  35. bool markOutputAsReadyToSend(const size_t /*outputIdx*/, const uint64_t /*startTime*/, const uint64_t /*endTime*/) override { return true; }
  36. CIdentifier getClassIdentifier() const override { return 0; }
  37. CMemoryBuffer m_InBuffer;
  38. CMemoryBuffer m_OutBuffer;
  39. };
  40. } // namespace Kernel
  41. } // namespace OpenViBE
  42. /**
  43. * \class BoxAlgorithmProxy
  44. * \brief This proxy is needed in order to use the stream codecs from the toolkit
  45. * \author J. T. Lindgren
  46. *
  47. */
  48. class BoxAlgorithmProxy final : protected OpenViBE::Tracker::Contexted
  49. {
  50. public:
  51. explicit BoxAlgorithmProxy(const OpenViBE::Kernel::IKernelContext& ctx) : Contexted(ctx) { }
  52. OpenViBE::Kernel::IBoxIO& getDynamicBoxContext() { return dummy; }
  53. static bool markAlgorithmAsReadyToProcess() { return true; }
  54. OpenViBE::Kernel::IAlgorithmManager& getAlgorithmManager() const override { return Contexted::getAlgorithmManager(); }
  55. OpenViBE::Kernel::IBoxIOProxy dummy;
  56. };