8#ifndef META_OCEAN_DEVICES_SERIALIZATION_SERIALIZER_DEVICE_PLAYER_H
9#define META_OCEAN_DEVICES_SERIALIZATION_SERIALIZER_DEVICE_PLAYER_H
92 using ChannelDeviceMap = std::unordered_map<IO::Serialization::DataSerializer::ChannelId, DeviceRef>;
97 using ChannelPixelImageMap = std::unordered_map<IO::Serialization::DataSerializer::ChannelId, Media::PixelImageRef>;
107 using SampleTypeMap = std::unordered_map<std::string, SampleProcessorFunction>;
112 using ChannelProcessorMap = std::unordered_map<IO::Serialization::DataSerializer::ChannelId, SampleProcessorFunction>;
154 using SamplePair = std::pair<IO::Serialization::DataSerializer::ChannelId, IO::Serialization::UniqueDataSample>;
186 bool start(
const float speed = 1.0f)
override;
208 inline double duration()
const override;
454 ocean_assert(
false &&
"This function is not supported");
Definition of a class holding the major and minor device type.
Definition devices/Device.h:62
This class is the base class for all devices of any type.
Definition devices/Device.h:28
TransformationResult
Definition of individual transformation results.
Definition DevicePlayer.h:53
DevicePlayer()=default
Creates a new device player.
Lock lock_
The player's lock.
Definition DevicePlayer.h:147
bool update(const IO::Serialization::MediaSerializer::DataSampleFrame &frameSample)
Updates the frame medium data with a new frame sample.
Media::PixelImageRef pixelImage_
The pixel image object.
Definition SerializerDevicePlayer.h:139
SharedAnyCamera camera_
The camera profile.
Definition SerializerDevicePlayer.h:142
HomogenousMatrixD4 device_T_camera_
The transformation between device and camera.
Definition SerializerDevicePlayer.h:145
FrameMediumData()=default
bool registerUsage()
Informs the manager that the player will be used.
Lock lock_
The manager's lock.
Definition SerializerDevicePlayer.h:81
UsageManager()=default
Default constructor.
bool isUsed_
True, if the player is currently used.
Definition SerializerDevicePlayer.h:78
void unregisterUsage()
Informs the manager that the player is not longer used.
bool start(const float speed=1.0f) override
Starts the replay.
bool isStarted() const override
Returns whether this player is currently started.
Definition SerializerDevicePlayer.h:465
void processDataSamplePositionTracker3DOF(const IO::Serialization::DataSerializer::ChannelId channelId, IO::Serialization::UniqueDataSample &&sample)
Processes a DataSamplePositionTracker3DOF sample.
~SerializerDevicePlayer() override
Destructs the device player.
Devices::DeviceRef DeviceRef
Alias for DeviceRef.
Definition SerializerDevicePlayer.h:87
float speed_
The speed at which the recording will be played, with range (0, infinity), 0 to play the recording wi...
Definition SerializerDevicePlayer.h:434
void processDataSampleGPSTracker(const IO::Serialization::DataSerializer::ChannelId channelId, IO::Serialization::UniqueDataSample &&sample)
Processes a DataSampleGPSTracker sample.
void processLookaheadSamples(const IO::Serialization::DataTimestamp &dataTimestamp, const double maxPlaybackTimestamp)
Processes samples within the lookahead window.
static Device * createPositionTracker3DOF(const std::string &name, const Device::DeviceType &deviceType)
Factory function for creating SerializationPositionTracker3DOF devices.
void processDataSampleGravityTracker3DOF(const IO::Serialization::DataSerializer::ChannelId channelId, IO::Serialization::UniqueDataSample &&sample)
Processes a DataSampleGravityTracker3DOF sample.
std::unordered_map< IO::Serialization::DataSerializer::ChannelId, DeviceRef > ChannelDeviceMap
Definition of a map mapping channel ids to device objects.
Definition SerializerDevicePlayer.h:92
DeviceRef ensureDevice(const IO::Serialization::DataSerializer::ChannelId channelId, const std::string &deviceName, const Device::DeviceType &deviceType)
Creates or retrieves a device for a specific channel.
Media::FrameMediumRefs frameMediums() override
Returns all media objects which have been created based on the recording.
Definition SerializerDevicePlayer.h:458
SampleQueue stopMotionSampleQueue_
The sample queue holding pending samples for the stop-motion mode.
Definition SerializerDevicePlayer.h:440
ChannelDeviceMap channelDeviceMap_
The map associating channel ids with device objects.
Definition SerializerDevicePlayer.h:419
static Device * createTracker6DOF(const std::string &name, const Device::DeviceType &deviceType)
Factory function for creating SerializationTracker6DOF devices.
std::unordered_map< IO::Serialization::DataSerializer::ChannelId, Media::PixelImageRef > ChannelPixelImageMap
Definition of a map mapping channel ids to PixelImage objects.
Definition SerializerDevicePlayer.h:97
bool isValid() const override
Returns whether this player holds a valid recording.
bool setStopMotionTolerance(const IO::Serialization::DataTimestamp &stopMotionTolerance)
Sets the tolerance for stop-motion playback mode.
void processSample(const IO::Serialization::DataSerializer::ChannelId channelId, IO::Serialization::UniqueDataSample &&sample)
Processes a sample and forwards it to the appropriate device.
void processDataSampleTracker6DOF(const IO::Serialization::DataSerializer::ChannelId channelId, IO::Serialization::UniqueDataSample &&sample)
Processes a DataSampleTracker6DOF sample.
std::unique_ptr< IO::Serialization::FileInputDataSerializer > inputSerializer_
The input data serializer for reading the content.
Definition SerializerDevicePlayer.h:413
bool stop() override
Stops the replay.
std::unordered_map< std::string, SampleProcessorFunction > SampleTypeMap
Definition of a map mapping sample type strings to specialized processing functions.
Definition SerializerDevicePlayer.h:107
double duration() const override
Returns the duration of the content when played with default speed.
Definition SerializerDevicePlayer.h:452
std::atomic_bool isStarted_
True, if the player is started.
Definition SerializerDevicePlayer.h:431
void processDataSampleOrientationTracker3DOF(const IO::Serialization::DataSerializer::ChannelId channelId, IO::Serialization::UniqueDataSample &&sample)
Processes a DataSampleOrientationTracker3DOF sample.
IO::Serialization::DataSerializer::ChannelId firstMediaFrameChannelId_
The id of the channel which is the first channel with media content.
Definition SerializerDevicePlayer.h:416
static Device * createAccelerationSensor3DOF(const std::string &name, const Device::DeviceType &deviceType)
Factory function for creating SerializationAccelerationSensor3DOF devices.
static Device * createGyroSensor3DOF(const std::string &name, const Device::DeviceType &deviceType)
Factory function for creating SerializationGyroSensor3DOF devices.
SerializerDevicePlayer()=default
Creates a new device player.
Media::FrameMediumRefs frameMediums_
The FrameMedium objects receiving image content from the recording.
Definition SerializerDevicePlayer.h:425
void(SerializerDevicePlayer::*)(const IO::Serialization::DataSerializer::ChannelId, IO::Serialization::UniqueDataSample &&) SampleProcessorFunction
Definition of a function pointer for specialized sample processing functions.
Definition SerializerDevicePlayer.h:102
void threadRun() override
The thread's run function in which the samples are read.
Timestamp playNextFrame() override
Plays the next frame of the recording, the player must be started with stop-motion mode.
bool initializeDeviceFactories()
Initializes the device factories by registering factory functions for all supported sample types.
ChannelFrameMediumDataMap channelFrameMediumDataMap_
The map associating channel ids with FrameMediumData objects.
Definition SerializerDevicePlayer.h:422
std::deque< SamplePair > SampleQueue
Definition of a queue holding sample pairs.
Definition SerializerDevicePlayer.h:157
void processDataSampleGyroSensor3DOF(const IO::Serialization::DataSerializer::ChannelId channelId, IO::Serialization::UniqueDataSample &&sample)
Processes a DataSampleGyroSensor3DOF sample.
IO::Serialization::DataTimestamp stopMotionTolerance_
The tolerance for stop-motion playback defining a time window beyond the current frame's timestamp fo...
Definition SerializerDevicePlayer.h:443
void release()
Stops playback and releases the player.
SampleTypeMap sampleTypeMap_
Map associating sample type strings with specialized processing functions.
Definition SerializerDevicePlayer.h:437
bool isPlaying() const
Returns whether this player is currently playing.
std::pair< IO::Serialization::DataSerializer::ChannelId, IO::Serialization::UniqueDataSample > SamplePair
Definition of a pair holding a channel id and a unique data sample.
Definition SerializerDevicePlayer.h:154
bool initialize(const std::string &filename) override
Loads a new serialized file for replay.
static Device * createOrientationTracker3DOF(const std::string &name, const Device::DeviceType &deviceType)
Factory function for creating SerializationOrientationTracker3DOF devices.
std::unordered_map< IO::Serialization::DataSerializer::ChannelId, SampleProcessorFunction > ChannelProcessorMap
Definition of a map mapping channel ids to specialized processing functions.
Definition SerializerDevicePlayer.h:112
void processDataSampleFrame(const IO::Serialization::DataSerializer::ChannelId channelId, IO::Serialization::UniqueDataSample &&sample)
Processes a DataSampleFrame sample.
static Device * createGPSTracker(const std::string &name, const Device::DeviceType &deviceType)
Factory function for creating SerializationGPSTracker devices.
ChannelProcessorMap channelProcessorMap_
The map associating channel ids with specialized processing functions.
Definition SerializerDevicePlayer.h:428
TransformationResult transformation(const std::string &name, const Timestamp ×tamp, HomogenousMatrixD4 &matrix) override
Returns a specific transformation which is expected to be part of the recording.
std::unordered_map< IO::Serialization::DataSerializer::ChannelId, FrameMediumData > ChannelFrameMediumDataMap
Definition of a map mapping channel ids to FrameMediumData objects.
Definition SerializerDevicePlayer.h:151
void processDataSampleAccelerationSensor3DOF(const IO::Serialization::DataSerializer::ChannelId channelId, IO::Serialization::UniqueDataSample &&sample)
Processes a DataSampleAccelerationSensor3DOF sample.
static Device * createGravityTracker3DOF(const std::string &name, const Device::DeviceType &deviceType)
Factory function for creating SerializationGravityTracker3DOF devices.
static constexpr ChannelId invalidChannelId()
Returns an invalid channel id.
Definition DataSerializer.h:360
uint32_t ChannelId
Definition of a channel id.
Definition DataSerializer.h:44
This class implements a data timestamp which can hold either a double or int64_t value.
Definition DataTimestamp.h:32
This class implements a recursive lock object.
Definition Lock.h:31
This class implements a scoped lock object for recursive lock objects.
Definition Lock.h:147
Thread(const std::string &name=std::string())
Creates a new thread object.
This class implements a timestamp.
Definition Timestamp.h:64
ObjectRef< Device > DeviceRef
This class implements a device reference with an internal reference counter.
Definition DeviceRef.h:27
std::unique_ptr< DataSample > UniqueDataSample
Definition of a unique pointer holding a DataSample.
Definition DataSample.h:39
HomogenousMatrixT4< double > HomogenousMatrixD4
Instantiation of the HomogenousMatrixT4 template class using a double precision float data type.
Definition HomogenousMatrix4.h:51
std::shared_ptr< AnyCamera > SharedAnyCamera
Definition of a shared pointer holding an AnyCamera object with Scalar precision.
Definition AnyCamera.h:61
Namespace of the Devices Serialization library.
Definition DeviceSerializer.h:32
Namespace of the Devices library.
Definition AccelerationSensor3DOF.h:24
The namespace covering the entire Ocean framework.
Definition Accessor.h:15