playback_device.h
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2017 Intel Corporation. All Rights Reserved.
3 
4 #pragma once
5 #include <atomic>
6 #include <core/roi.h>
7 #include <core/extension.h>
8 #include <core/serialization.h>
9 #include "core/streaming.h"
10 #include "archive.h"
11 #include "concurrency.h"
12 #include "sensor.h"
13 #include "playback_sensor.h"
14 
15 namespace librealsense
16 {
18  public extendable_interface,
19  public info_container
20  {
21  public:
22  playback_device(std::shared_ptr<context> context, std::shared_ptr<device_serializer::reader> serializer);
23  virtual ~playback_device();
24 
25  std::shared_ptr<context> get_context() const override;
26 
27  sensor_interface& get_sensor(size_t i) override;
28  size_t get_sensors_count() const override;
29  const sensor_interface& get_sensor(size_t i) const override;
30  void hardware_reset() override;
31  bool extend_to(rs2_extension extension_type, void** ext) override;
32  std::shared_ptr<matcher> create_matcher(const frame_holder& frame) const override;
33 
34  void set_frame_rate(double rate);
37  uint64_t get_duration() const;
38  void pause();
39  void resume();
40  void stop();
41  void set_real_time(bool real_time);
42  bool is_real_time() const;
43  const std::string& get_file_name() const;
44  uint64_t get_position() const;
47  std::pair<uint32_t, rs2_extrinsics> get_extrinsics(const stream_interface& stream) const override;
48  static bool try_extend_snapshot(std::shared_ptr<extension_snapshot>& e, rs2_extension extension_type, void** ext);
49  bool is_valid() const override;
50 
51  std::vector<tagged_profile> get_profiles_tags() const override { return std::vector<tagged_profile>(); };//no hard-coded default streams for playback
52  void tag_profiles(stream_profiles profiles) const override
53  {
54  for(auto profile : profiles)
56  }
57 
58  bool compress_while_record() const override { return true; }
59  bool contradicts(const stream_profile_interface* a, const std::vector<stream_profile>& others) const override { return false; }
60 
61  private:
64  void start();
65  void stop_internal();
66  void try_looping();
67  template <typename T> void do_loop(T op);
68  std::map<uint32_t, std::shared_ptr<playback_sensor>> create_playback_sensors(const device_serializer::device_snapshot& device_description);
69  std::shared_ptr<stream_profile_interface> get_stream(const std::map<unsigned, std::shared_ptr<playback_sensor>>& sensors_map, device_serializer::stream_identifier stream_id);
71  void catch_up();
72  void register_device_info(const device_serializer::device_snapshot& device_description);
73  void register_extrinsics(const device_serializer::device_snapshot& device_description);
74  void update_extensions(const device_serializer::device_snapshot& device_description);
75  bool prefetch_done();
76 
77  private:
79  std::shared_ptr<context> m_context;
80  std::shared_ptr<device_serializer::reader> m_reader;
82  std::atomic_bool m_is_started;
83  std::atomic_bool m_is_paused;
84  std::chrono::high_resolution_clock::time_point m_base_sys_time; // !< System time when reading began (first frame was read)
85  device_serializer::nanoseconds m_base_timestamp; // !< Timestamp of the first frame that has a real timestamp (different than 0)
86  std::map<uint32_t, std::shared_ptr<playback_sensor>> m_sensors;
87  std::map<uint32_t, std::shared_ptr<playback_sensor>> m_active_sensors;
88  std::atomic<double> m_sample_rate;
89  std::atomic_bool m_real_time;
91  std::vector<std::shared_ptr<lazy<rs2_extrinsics>>> m_extrinsics_fetchers;
92  std::map<int, std::pair<uint32_t, rs2_extrinsics>> m_extrinsics_map;
95  };
96 
98 }
rs2_extrinsics calc_extrinsic(const rs2_extrinsics &from, const rs2_extrinsics &to)
std::shared_ptr< context > get_context() const override
void register_extrinsics(const device_serializer::device_snapshot &device_description)
void tag_profiles(stream_profiles profiles) const override
std::shared_ptr< stream_profile_interface > get_stream(const std::map< unsigned, std::shared_ptr< playback_sensor >> &sensors_map, device_serializer::stream_identifier stream_id)
void seek_to_time(std::chrono::nanoseconds time)
std::shared_ptr< context > m_context
playback_device(std::shared_ptr< context > context, std::shared_ptr< device_serializer::reader > serializer)
const std::string & get_file_name() const
GLsizei const GLchar *const * string
lazy< std::shared_ptr< dispatcher > > m_read_thread
signal< playback_device, rs2_playback_status > playback_status_changed
e
Definition: rmse.py:177
platform::backend_device_group get_device_data() const override
bool extend_to(rs2_extension extension_type, void **ext) override
static bool try_extend_snapshot(std::shared_ptr< extension_snapshot > &e, rs2_extension extension_type, void **ext)
GLboolean GLboolean GLboolean GLboolean a
bool compress_while_record() const override
bool contradicts(const stream_profile_interface *a, const std::vector< stream_profile > &others) const override
device_serializer::nanoseconds m_prev_timestamp
GLuint GLenum * rate
Definition: glext.h:10991
device_serializer::nanoseconds m_last_published_timestamp
rs2_playback_status
size_t get_sensors_count() const override
unsigned __int64 uint64_t
Definition: stdint.h:90
std::shared_ptr< device_serializer::reader > m_reader
std::atomic< double > m_sample_rate
device_serializer::nanoseconds m_base_timestamp
bool is_valid() const override
std::map< uint32_t, std::shared_ptr< playback_sensor > > m_active_sensors
void set_real_time(bool real_time)
std::vector< std::shared_ptr< stream_profile_interface >> stream_profiles
Definition: streaming.h:165
std::chrono::duration< uint64_t, std::nano > nanoseconds
std::map< uint32_t, std::shared_ptr< playback_sensor > > create_playback_sensors(const device_serializer::device_snapshot &device_description)
Cross-stream extrinsics: encodes the topology describing how the different devices are oriented...
Definition: rs_sensor.h:96
rs2_playback_status get_current_status() const
std::vector< tagged_profile > get_profiles_tags() const override
rs2_extension
Specifies advanced interfaces (capabilities) objects may implement.
Definition: rs_types.h:166
int stream_id
Definition: sync.h:17
device_serializer::device_snapshot m_device_description
int i
void update_time_base(device_serializer::nanoseconds base_timestamp)
void register_device_info(const device_serializer::device_snapshot &device_description)
std::shared_ptr< matcher > create_matcher(const frame_holder &frame) const override
sensor_interface & get_sensor(size_t i) override
std::pair< uint32_t, rs2_extrinsics > get_extrinsics(const stream_interface &stream) const override
GeneratorWrapper< T > map(Func &&function, GeneratorWrapper< U > &&generator)
Definition: catch.hpp:4271
std::map< int, std::pair< uint32_t, rs2_extrinsics > > m_extrinsics_map
MAP_EXTENSION(RS2_EXTENSION_POINTS, librealsense::points)
std::vector< std::shared_ptr< lazy< rs2_extrinsics > > > m_extrinsics_fetchers
std::map< uint32_t, std::shared_ptr< playback_sensor > > m_sensors
std::chrono::high_resolution_clock::time_point m_base_sys_time
void update_extensions(const device_serializer::device_snapshot &device_description)
device_serializer::nanoseconds calc_sleep_time(device_serializer::nanoseconds timestamp)


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:47:39